home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Text / hyper / guidemlppc.lha / GuideML / GuideML.c < prev    next >
C/C++ Source or Header  |  2004-09-04  |  121KB  |  3,839 lines

  1. /***************************************************************
  2. **                                                            **
  3. **      GuideML -- Converts AmigaGuide into HTML              **
  4. **                                                            **
  5. ***************************************************************/
  6. /*
  7. **  Copyright (C) 1997-98 Richard Körber  --  All Rights Reserved
  8. **    E-Mail: shred@eratosthenes.starfleet.de
  9. **    URL:    http://shredzone.home.pages.de
  10. **
  11. ** Updated 2001-2004 by Chris Young
  12. ** chris@unsatisfactorysoftware.co.uk
  13. ** http://www.unsatisfactorysoftware.co.uk
  14. ***************************************************************/
  15. /* compile with
  16.    gcc guideml.c -o guideml -lauto -lraauto
  17.  */
  18. /*
  19. **  This program is free software; you can redistribute it and/or modify
  20. **  it under the terms of the GNU General Public License as published by
  21. **  the Free Software Foundation; either version 2 of the License, or
  22. **  any later version.
  23. **
  24. **  This program is distributed in the hope that it will be useful,
  25. **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  27. **  GNU General Public License for more details.
  28. **
  29. **  You should have received a copy of the GNU General Public License
  30. **  along with this program; if not, write to the Free Software
  31. **  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  32. **
  33. **  The author (Richard Körber) reserves the right to revoke the
  34. **  GNU General Public License whenever he feels that it is necessary,
  35. **  especially when he found out that the licence has been abused,
  36. **  ignored or violated, and without prior notice.
  37. **
  38. **  You must not use this source code to gain profit of any kind!
  39. **
  40. ***************************************************************/
  41. /*
  42. ** If you use an editor that is capable of text folding, use
  43. ** "//>" and "//<" as begin and end fold markers, respectively.
  44. */
  45.  
  46. #include <stdio.h>
  47. #include <string.h>
  48. // #include <proto/alib.h>
  49. #include <proto/exec.h>
  50. #include <proto/dos.h>
  51. #include <proto/gadtools.h>
  52. #include <proto/utility.h>
  53. #include <exec/lists.h>
  54. #include <exec/nodes.h>
  55. #include <exec/memory.h>
  56. #include <exec/exec.h>
  57. #include <dos/dos.h>
  58. #include <libraries/dos.h>
  59.  
  60. #include <exec/types.h>
  61. #include <exec/io.h>
  62. #include <proto/asl.h>
  63. #include <proto/intuition.h>
  64. #include <proto/window.h>
  65. #include <proto/layout.h>
  66. #include <proto/checkbox.h>
  67. #include <proto/button.h>
  68. #include <proto/label.h>
  69. #include <proto/chooser.h>
  70. #include <proto/getfile.h>
  71. #include <proto/clicktab.h>
  72. #include <proto/string.h>
  73. // #include <clib/integer_protos.h>
  74. // #include <clib/listbrowser_protos.h>
  75. #include <proto/gadtools.h>
  76. #include <proto/icon.h>
  77.  
  78. #include <intuition/intuition.h>
  79. #include <intuition/icclass.h>
  80. #include <libraries/gadtools.h>
  81. #include <workbench/icon.h>
  82.  
  83. #include <stdlib.h>
  84.  
  85. #include <classes/window.h>
  86. #include <gadgets/layout.h>
  87. #include <gadgets/checkbox.h>
  88. #include <gadgets/button.h>
  89. #include <gadgets/chooser.h>
  90. #include <gadgets/clicktab.h>
  91. // #include <gadgets/integer.h>
  92. #include <gadgets/string.h>
  93. // #include <gadgets/listbrowser.h>
  94. #include <gadgets/getfile.h>
  95. #include <images/label.h>
  96.  
  97. //#include <reaction/reaction.h>
  98. #include <reaction/reaction_macros.h>
  99.  
  100.  
  101.  
  102. #define VERSIONSTR "3.7"                 /* Version Nr */
  103. #define VERSIONDATE "04.09.2004"            /* Version Date */
  104. #define LINELEN (1024)                    /* Maximum length of a line */
  105.  
  106. struct Library *GadToolsBase;
  107. struct GadToolsIFace *IGadTools;
  108. struct Library *UtilityBase;
  109. struct UtilityIFace *IUtility;
  110.  
  111. /*
  112. extern struct Library *DOSBase;
  113. struct Library *aslbase;
  114. struct Library *WindowBase;
  115. struct Library *LayoutBase;
  116. struct Library *ButtonBase;
  117. struct Library *CheckBoxBase;
  118. struct Library *LabelBase;
  119. struct Library *ChooserBase;
  120. struct Library *ClickTabBase;
  121. // struct Library *IntegerBase;
  122. struct Library *StringBase;
  123. // struct Library *ListBrowserBase;
  124. struct Library *GetFileBase;
  125. struct Library *IconBase;
  126. */
  127.  
  128. int err(char *,char *,int);
  129. void ui();
  130. void free_list(struct List *);
  131. void freetablist(struct List *);
  132. BOOL make_list(struct List *, UBYTE **);
  133. BOOL maketablist(struct List *, UBYTE **);
  134. void gettooltypes(); // struct WBArg *);
  135. struct Menu *addmenu(struct Window *);
  136. void cleanup(int);
  137. int wbmain(struct WBStartup *);
  138.  
  139. enum
  140. {
  141.     GID_MAIN=0,
  142.     GID_CONV,
  143.     GID_FILE,
  144.     GID_TO,
  145.     GID_HOMEURL,
  146.     GID_FINDURL,
  147.     GID_PREV,
  148.     GID_NEXT,
  149.     GID_INDEX,
  150.     GID_TOC,
  151.     GID_HELP,
  152.     GID_RETRACE,
  153.     GID_HOME,
  154.     GID_FIND,
  155.     GID_BAR,
  156.     GID_BODY,
  157.     GID_LINKS,
  158.     GID_MSDOS,
  159.     GID_SINGLEFILE,
  160.     GID_NOHTML,
  161.     GID_CSS,
  162.     GID_LA,
  163.     GID_HTMLHEADF,
  164.     GID_HTMLFOOTF,
  165.     GID_WRAP,
  166.     GID_VARWIDTH,
  167.     GID_NAVBAR,
  168.     GID_MOZNAV,
  169.     GID_IMAGES,
  170.     GID_SHOWALL,
  171.     GID_TABS,
  172.     GID_PAGE,
  173.     GID_LAST
  174. };
  175.  
  176. enum
  177. {
  178.     WID_MAIN=0,
  179.     WID_LAST
  180. };
  181.  
  182. enum
  183. {
  184.     OID_MAIN=0,
  185.     OID_LAST
  186. };
  187.  
  188. struct Gadget *gadgets[GID_LAST];
  189.  
  190. char VerStr[] = "\0$VER: GuideML "VERSIONSTR" ("VERSIONDATE")";
  191.   static unsigned char defbar[] = " | ";
  192. //    struct WBArg *wbarg;
  193.  
  194.  
  195. struct Parameter                          /* Structure of Shell parameters */
  196. {
  197.   STRPTR from;
  198.   STRPTR to;
  199.   STRPTR homeurl;
  200.   STRPTR findurl;
  201.   STRPTR prev;
  202.   STRPTR next;
  203.   STRPTR index;
  204.   STRPTR toc;
  205.   STRPTR help;
  206.   STRPTR retrace;
  207.   STRPTR home;
  208.   STRPTR find;
  209.   STRPTR bar;
  210.   STRPTR bodyext;
  211.   LONG   verbatim;
  212.   LONG   images;
  213.   LONG   footer;
  214.   STRPTR linkadd;
  215.   LONG   nolink;
  216.   LONG   noemail;
  217.   LONG   nowarn;
  218.   LONG   msdos;
  219.   LONG   singlefile;
  220.   LONG   nonavbar;
  221.   LONG   nomoznav;
  222.   LONG   showall;
  223.   STRPTR htmltoptxt;
  224.   STRPTR htmlheadf;
  225.   STRPTR htmlbottxt;
  226.   STRPTR htmlfootf;
  227.   LONG   nohtml;
  228.   STRPTR cssurl;
  229.   LONG   wordwrap;
  230.   LONG    smartwrap;
  231.   LONG   varwidth;
  232.   LONG     noauto;
  233. }param = {NULL};
  234.  
  235.   long *htmltop;
  236.   long *htmlbot;
  237.  
  238. struct text
  239. {
  240.   STRPTR from;
  241.   STRPTR to;
  242.   STRPTR prev;
  243.   STRPTR next;
  244.   STRPTR index;
  245.   STRPTR toc;
  246.   STRPTR help;
  247.   STRPTR retrace;
  248.   STRPTR home;
  249.   STRPTR find;
  250.   STRPTR bar;
  251. };
  252.  
  253. struct text textlabs;
  254.  
  255. struct Entry                              /* List of all nodes and links */
  256. {
  257.   struct MinNode link;
  258.   ULONG Count;
  259.   char Node[100];
  260.   char Prev[100];
  261.   char Next[100];
  262.   char TOC[100];
  263.   char Help[100];
  264.   char Index[100];
  265.   char Titl[100];
  266. };
  267. struct MinList entries;
  268.  
  269. struct LinkStr                            /* Link bar alternative texts */
  270. {
  271.   char Prev[100];
  272.   char Next[100];
  273.   char Index[100];
  274.   char Toc[100];
  275.   char Home[100];
  276.   char Help[100];
  277.   char Find[100];
  278.   char Retrace[100];
  279. };
  280.  
  281. char Index[100];                          /* Index page name */
  282. char Help[100];
  283.  
  284. char temp[100];
  285.  
  286. //Some dummy memory-allocating rodents for tooltype porpoises.
  287. char *ttfrom = 0;
  288. char *ttto = 0;
  289. char *tthomeurl = 0;
  290. char *ttfindurl = 0;
  291. char *ttprev = 0;
  292. char *ttnext = 0;
  293. char *ttindex = 0;
  294. char *tttoc = 0;
  295. char *tthelp = 0;
  296. char *ttretrace = 0;
  297. char *tthome = 0;
  298. char *ttfind = 0;
  299. char *ttbar = 0;
  300. char *ttbody = 0;
  301. char *ttlinkadd = 0;
  302. char *tthtmlheadf = 0;
  303. char *tthtmlfootf = 0;
  304. char *ttcss = 0;
  305.  
  306. int wb=0;
  307. int ok=0;
  308.  
  309. char defname[100];
  310.  
  311. //> UBYTE Img#?[] = {...};
  312. /*
  313. **  These are the navigation bar images, in GIF format
  314. */
  315. UBYTE ImgHome[] =
  316. {
  317.   0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  318.   0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  319.   0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  320.   0x4A,0x08,0xBA,0x20,0xFC,0xB0,0x9D,0xD1,0x44,0x88,0x4B,0x9C,0x3D,0xF4,0xC5,0xDA,
  321.   0x26,0x1E,0x1F,0x14,0x8E,0x5B,0xC9,0x9C,0x28,0x69,0xB6,0x28,0x95,0x91,0x01,0x4B,
  322.   0x7B,0x73,0x70,0xD8,0x3A,0xAE,0x68,0x82,0x20,0x2A,0xE8,0x93,0xC0,0x50,0x25,0x4F,
  323.   0xED,0xC6,0x4C,0x92,0x76,0x4F,0x0F,0xD4,0x49,0x8C,0xEE,0x84,0xCE,0x51,0x0F,0x99,
  324.   0x09,0x78,0xBF,0xB4,0xAF,0x17,0x43,0x2E,0x9B,0x01,0x09,0x00,0x3B
  325.  
  326. };
  327. #define LEN_IMGHOME (0x7C)
  328.  
  329. UBYTE ImgIndex[] =
  330. {
  331.  0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  332.  0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  333.  0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  334.  0x41,0x28,0xBA,0xDC,0x12,0x40,0x9C,0x49,0xAB,0x85,0xD2,0x6A,0x8A,0x4F,0xF8,0x20,
  335.  0xE8,0x05,0x53,0xE7,0x2C,0x87,0x52,0x46,0x5B,0xDB,0x85,0xF0,0xB8,0x4A,0xA7,0xAA,
  336.  0x7A,0x6C,0xAB,0xBD,0xB0,0xF8,0xCD,0xA9,0x5A,0x10,0xA8,0xBB,0xB0,0x7A,0x3E,0x12,
  337.  0x8E,0x26,0xBC,0x75,0x8A,0x95,0x27,0x74,0x86,0xAC,0x42,0x00,0xD8,0xAC,0x76,0x9B,
  338.  0x4D,0x00,0x00,0x3B
  339.  
  340.  
  341. };
  342. #define LEN_IMGINDEX (0x73)
  343.  
  344. UBYTE ImgNext[] =
  345. {
  346.  0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  347.  0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  348.  0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  349.  0x33,0x08,0xBA,0x2A,0xFC,0xB0,0x8D,0x48,0x81,0x38,0xB3,0xBE,0x8B,0x35,0xE3,0xDD,
  350.  0x27,0x8C,0xE4,0x78,0x9C,0x61,0x83,0xAE,0x6C,0x0A,0xB6,0x6C,0xA0,0xC2,0xF1,0x22,
  351.  0x04,0x78,0x8E,0xAF,0xB2,0x07,0xF6,0xBE,0x13,0x30,0x38,0xF4,0x15,0x7D,0x9E,0xA4,
  352.  0x72,0xA9,0x4C,0x00,0x00,0x3B
  353.  
  354.  
  355. };
  356. #define LEN_IMGNEXT (0x65)
  357.  
  358. UBYTE ImgPrev[] =
  359. {
  360.  0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  361.  0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  362.  0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  363. 0x37,0x08,0xBA,0x10,0xFC,0x10,0x08,0x17,0xA3,0x38,0xB4,0xB2,0x8B,0xF5,0x3E,0x60,
  364. 0xA6,0x71,0xA0,0x60,0x9E,0xE7,0x42,0x82,0x6C,0xDB,0x01,0x83,0x2B,0xB3,0x59,0x3C,
  365. 0xBB,0xA2,0x1D,0x06,0x7C,0xCF,0x3F,0x3A,0x91,0xC7,0x26,0x1C,0xBE,0x3C,0x8C,0x41,
  366. 0x11,0xB9,0x44,0x3A,0x9F,0xD0,0x48,0x02,0x00,0x3B
  367.  
  368.  
  369. };
  370. #define LEN_IMGPREV (0x69)
  371.  
  372. UBYTE ImgTOC[] =
  373. {
  374.  0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  375.  0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  376.  0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  377. 0x34,0x08,0xBA,0x20,0xFC,0xB0,0x9D,0x11,0xA3,0x38,0x98,0xD6,0x75,0x71,0xDE,0x92,
  378. 0xE7,0x69,0x50,0x27,0x8E,0xE5,0xA9,0x92,0x4D,0xE0,0xBA,0xDE,0xFB,0x56,0x66,0x00,
  379. 0x72,0xF1,0xAD,0xD4,0x7A,0x78,0xD8,0x3A,0x5E,0x30,0x37,0xC4,0x00,0x6F,0x02,0x59,
  380. 0x6F,0xC9,0x54,0x24,0x00,0x00,0x3B
  381. };
  382. #define LEN_IMGTOC (0x66)
  383.  
  384. // below are temporary images
  385. UBYTE ImgHelp[] =
  386. {
  387.  0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  388.  0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  389.  0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  390. 0x36,0x08,0x2A,0xDC,0x32,0x2A,0x4A,0x71,0xAA,0xAD,0x50,0xAE,0xCB,0x4F,0xD0,0x00,
  391. 0x15,0x8C,0x24,0xE5,0x69,0xE6,0x37,0x55,0x6A,0x94,0xAE,0x27,0x28,0xB4,0x21,0x0B,
  392. 0xDE,0xEF,0x2D,0xC7,0x3A,0x4C,0xF7,0x0A,0x1E,0x70,0x08,0x64,0x10,0x5D,0xB6,0x63,
  393. 0xEE,0x38,0x3A,0x3A,0x9F,0x92,0x04,0x00,0x3B
  394.  
  395. };
  396. #define LEN_IMGHELP (0x68)
  397.  
  398. UBYTE ImgFind[] =
  399. {
  400.  0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  401.  0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  402.  0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  403. 0x42,0x08,0x0A,0xD2,0xBD,0x30,0x8A,0x43,0xE9,0x88,0x92,0x86,0x6D,0xB1,0x9A,0x47,
  404. 0xB0,0x0C,0x5D,0x16,0x46,0xE4,0x09,0x4D,0x22,0xC6,0x66,0x2D,0x2C,0xBB,0xEA,0x02,
  405. 0x5E,0xAB,0x86,0xA5,0x38,0xA3,0x7B,0x29,0x47,0xE5,0xD0,0x43,0x0D,0x43,0x95,0x22,
  406. 0x64,0xC3,0x04,0xA4,0x88,0x1E,0x60,0x32,0xBA,0xFB,0x51,0x21,0x83,0xCD,0x75,0xCB,
  407. 0x8D,0x24,0x00,0x00,0x3B
  408.  
  409. };
  410. #define LEN_IMGFIND (0x74)
  411.  
  412. UBYTE ImgRetrace[] =
  413. {
  414.  0x47,0x49,0x46,0x38,0x39,0x61,0x12,0x00,0x12,0x00,0xF2,0x00,0x00,0xCC,0xCC,0xCC,
  415.  0x00,0x00,0x00,0xFF,0xFF,0xFF,0x88,0x88,0x88,0xAA,0x22,0x00,0xDD,0x55,0x00,0xEE,
  416.  0xBB,0x00,0xAD,0xC1,0xD5,0x2C,0x00,0x00,0x00,0x00,0x12,0x00,0x12,0x00,0x02,0x03,
  417. 0x42,0x28,0x02,0xA0,0xCE,0x30,0x8A,0xA3,0x8E,0xB5,0x6A,0x44,0x36,0xAF,0xBF,0x9A,
  418. 0x74,0x05,0x24,0xE9,0x85,0xDC,0x18,0x0D,0xA0,0x54,0x92,0x6B,0xBB,0xCD,0xE9,0x11,
  419. 0xD0,0x74,0x77,0xE3,0x9B,0xCE,0xF7,0x96,0x5D,0x43,0x91,0x0B,0x8A,0x0E,0xA8,0x9A,
  420. 0xED,0x48,0x71,0x74,0x96,0x1B,0xD6,0x47,0x45,0x33,0x79,0x60,0xBF,0x97,0xF0,0xC7,
  421. 0xED,0xF2,0x12,0x00,0x3B
  422.  
  423. };
  424. #define LEN_IMGRETRACE (0x74)
  425.  
  426. //<
  427.  
  428. //> STRPTR entity[96] = {...};
  429. /*
  430. ** This are the full names of all HTML entities
  431. */
  432. STRPTR entity[96] =
  433. {
  434.   "nbsp","iexcl","cent","pound","curren","yen","brvbar","sect","uml",
  435.   "copy","ordf","laquo","not","shy","reg","macr","deg","plusmn","sup2",
  436.   "sup3","acute","micro","para","middot","cedil","sup1","ordm","raquo",
  437.   "frac14","frac12","frac34","iquest","Agrave","Aacute","Acirc","Atilde",
  438.   "Auml","Aring","AElig","Ccedil","Egrave","Eacute","Ecirc","Euml","Igrave",
  439.   "Iacute","Icirc","Iuml","ETH","Ntilde","Ograve","Oacute","Ocirc","Otilde",
  440.   "Ouml","times","Oslash","Ugrave","Uacute","Ucirc","Uuml","Yacute","THORN",
  441.   "szlig","agrave","aacute","acirc","atilde","auml","aring","aelig","ccedil",
  442.   "egrave","eacute","ecirc","euml","igrave","iacute","icirc","iuml","eth",
  443.   "ntilde","ograve","oacute","ocirc","otilde","ouml","divide","oslash",
  444.   "ugrave","uacute","ucirc","uuml","yacute","thorn","yuml"
  445. };
  446. //<
  447. //> STRPTR agpens[] , htmlpens[]
  448. /*
  449. ** This are the pen names in AmigaGuide documents
  450. */
  451. STRPTR agpens[] =
  452. {
  453.   "text}","shine}","shadow}","fill}","filltext}","background}","highlight}",
  454.   NULL
  455. };
  456.  
  457. /*
  458. ** And this are the appropriate HTML colors
  459. */
  460. STRPTR htmlpens[] =
  461. {
  462.   "#000000","#ffffff","#000000","#3864a0","#000000","#949494","#ffffff"
  463. };
  464.  
  465. STRPTR cssclass[] =
  466. {
  467.   "agtext","agshine","agshadow","agfill","agfilltext","agbackground","aghighlight"
  468. };
  469. //<
  470.  
  471. //> SaveImg()
  472. /*------------------------------------------------------------*
  473. *   SaveImg()        Saves one image                          *
  474. *     -> file File Name                                       *
  475. *     -> data Data buffer                                     *
  476. *     -> len  Length                                          *
  477. *     <-      Success                                         *
  478. */
  479. LONG SaveImg(STRPTR file, UBYTE *data, ULONG len)
  480. {
  481.   BPTR lock;
  482.  
  483.   if(lock = IDOS->Lock(file,ACCESS_READ))       // Already existing?
  484.   {
  485.     IDOS->UnLock(lock);
  486.     return(1);                            // then leave with success
  487.   }
  488.  
  489.   if(param.verbatim) printf("Creating image '%s'\n",file);  // Report
  490.  
  491.   if(lock = IDOS->Open(file,MODE_NEWFILE))      // Open the image file
  492.   {
  493.     if(-1 == IDOS->Write(lock,data,len))        // Write the image
  494.     {
  495.       IDOS->Close(lock);                        // Write failed, so
  496.       return(0);                          // return without success
  497.     }
  498.     IDOS->Close(lock);                          // Write succeeded, so
  499.     return(1);                            // return with success
  500.   }
  501.   return(0);                              // No lock, no success
  502. }
  503. //<
  504. //> SaveImages()
  505. /*------------------------------------------------------------*
  506. *   SaveImages()     Saves all required images                *
  507. *     <-      Success                                         *
  508. */
  509. LONG SaveImages(void)
  510. {
  511.   for(;;)
  512.   {
  513.     if(param.homeurl)
  514.       if(!SaveImg("home.gif" ,ImgHome ,LEN_IMGHOME )) break;
  515.     if(param.retrace)
  516.       if(!SaveImg("retrace.gif" ,ImgRetrace ,LEN_IMGRETRACE )) break;
  517.     if(param.help)
  518.       if(!SaveImg("help.gif" ,ImgHelp ,LEN_IMGHELP )) break;
  519.     if(param.findurl)
  520.       if(!SaveImg("find.gif" ,ImgFind ,LEN_IMGFIND )) break;
  521.  
  522. //    if(*Index)
  523.       if(!SaveImg("index.gif",ImgIndex,LEN_IMGINDEX)) break;
  524.  
  525.     if(!SaveImg("next.gif" ,ImgNext ,LEN_IMGNEXT )) break;
  526.     if(!SaveImg("prev.gif" ,ImgPrev ,LEN_IMGPREV )) break;
  527.     if(!SaveImg("toc.gif"  ,ImgTOC  ,LEN_IMGTOC  )) break;
  528.     return(1);
  529.   }
  530.   return(0);
  531. }
  532. //<
  533.  
  534. //> CopyLink()
  535. /*------------------------------------------------------------*
  536. *   CopyLink()       Copies a link file name into a variable  *
  537. *     -> link Link                                            *
  538. *     -> var  String-Var                                      *
  539. */
  540. void CopyLink(STRPTR link, STRPTR var)
  541. {
  542.   char ch;
  543.  
  544.   var[0] = '\0';                          // Init
  545.  
  546.     strcpy(var,param.linkadd);
  547.     var=var+strlen(param.linkadd);
  548.  
  549.   while(*link && *link==' ') link++;      // Suppress spaces
  550.   if(!*link) return;                      //   there were only spaces!
  551.  
  552.   if(*link != '\"')
  553.   {                                       // Quick Mode
  554.     while((ch = *link++)!=' ' && ch!='\n')
  555.     {
  556.       if(ch==':') ch='/'; // colon to slash again
  557.       if(ch>='A' && ch<='Z') ch+=32; // upper to lower again
  558.       *var++ = ch;
  559.     }
  560.   }
  561.   else
  562.   {                                       // Quote Mode
  563.     link++;                               //   we had a leading quote
  564.     if(!*link) return;
  565.     while((ch = *link++)!='\"' && ch!='\n')
  566.     {
  567.       if(ch==' ') ch = '_'; // space converts to underscore
  568.       if(ch==':') ch = '/'; // colon converts to slash
  569.       if(ch>='A' && ch<='Z') ch+=32; // uppercase converts to lowercase
  570.       *var++ = ch;
  571.     }
  572.   }
  573.  
  574.   *var++ = '.';                           // Add html suffix
  575.   *var++ = 'h';
  576.   *var++ = 't';
  577.   *var++ = 'm';
  578.   if(!param.msdos) *var++ = 'l';
  579.   *var = '\0';
  580. }
  581. //<
  582. //> MyPutCh()
  583. /*------------------------------------------------------------*
  584. *   MyPutCh()       Writes single chars into HTML             *
  585. *     -> fh   output file handle                              *
  586. *     -> ch   Amiga char to be written                        *
  587. *     <-      -1 for failure                                  *
  588. */
  589. LONG MyPutCh(BPTR fh, unsigned char ch)
  590. {
  591.   if(ch<' ' && ch!='\n')                // Is it a control char?
  592.   {
  593.     return IDOS->FPrintf(fh,"&#%03ld;",ch);   //   yes: return them as number
  594.   }
  595.   else if(ch < 128)                     // Is it an ASCII char?
  596.   {
  597.     if(ch=='\"') return IDOS->FPuts(fh,""");     // Convert some exceptions
  598.     else if(ch=='&') return IDOS->FPuts(fh,"&");
  599.     else if(ch=='<') return IDOS->FPuts(fh,"<");   // #060
  600.     else if(ch=='>') return IDOS->FPuts(fh,">"); // #062
  601.     else return IDOS->FPutC(fh,ch);                   // else put char directly
  602.   }
  603.   else                                  // Chars >127 ?
  604.   {
  605.     if(ch>=160)                         // Do we have an entity name?
  606.       return IDOS->FPrintf(fh,"&%s;",entity[ch-160]); // yes: use this one
  607.     else
  608.       return IDOS->FPrintf(fh,"&#%03ld;",ch);         // no: use it's number
  609.   }
  610. }
  611. //<
  612. //> MyPuts()
  613. /*------------------------------------------------------------*
  614. *   MyPuts()        Writes a string into HTML                 *
  615. *     -> fh   Output file handle                              *
  616. *     -> str  String to be output                             *
  617. *     <-      -1 for failure                                  *
  618. */
  619. LONG MyPuts(BPTR fh, STRPTR str)
  620. {
  621.   unsigned char ch;
  622.  
  623.   while(ch = *str++)                        // go through the string
  624.   {
  625.     if(ch=='\"' || ch=='<' || ch=='>' || ch=='&')      // do NOT convert them
  626.     {                                       //  since they are also used
  627.       if(-1 == IDOS->FPutC(fh,ch)) return(-1);    //  in HTML tags
  628.     }
  629.     else
  630.     {
  631.       if(-1 == MyPutCh(fh,ch)) return(-1);
  632.     }
  633.   }
  634.   return(0);
  635. }
  636. //<
  637. //> ConvLine()
  638. /*------------------------------------------------------------*
  639. *   ConvLine()      Converts an AmigaGuide line               *
  640. *     -> fh   output file handle                              *
  641. *     -> buf  Source buffer                                   *
  642. *     -> linenr line number                                   *
  643. *     <-      Success                                         *
  644. */
  645. LONG ConvLine(BPTR fh, STRPTR buf, ULONG linenr)
  646. {
  647.   unsigned char ch;
  648.   char linkstr[100];
  649.   register UWORD dolink  = !param.nolink;
  650.   register UWORD doemail = !param.noemail;
  651.  
  652. if((param.smartwrap) && (strlen(buf)<2))
  653.     {
  654.     if(-1 == IDOS->FPuts(fh,"<br>")) return(0);
  655.     }
  656.  
  657.   while(ch = *buf++)                      // while chars available
  658.   {
  659.     if('\\'==ch)                          //   backslash escape character?
  660.     {
  661.       switch(*buf)
  662.       {
  663.         case '\\':                        // '\\' -> '\'
  664.         case '@':                         // '\@' -> '@'
  665.           if(-1 == MyPutCh(fh,*buf)) return(0);
  666.           buf++;
  667.           break;
  668.       }
  669.       continue;
  670.     }
  671.  
  672.     if(doemail)                           // email recognition activated?
  673.     {
  674.       if(  (ch>='a' && ch<='z')           // Could this be a valid email?
  675.          ||(ch>='A' && ch<='Z')
  676.          ||(ch>='0' && ch<='9'))
  677.       {
  678.         UWORD length   = 0;   // length of the email string
  679.         UWORD atfound  = 0;   // how many '@' were found?
  680.         UWORD charcnt  = 0;   // how many characters in total?
  681.         UWORD dotfound = 0;   // how many dots?
  682.         UWORD atdot    = 0;   // how many dots after the '@'?
  683.         UWORD chardot  = 0;   // how many chars after the last dot?
  684.         STRPTR index   = --buf;
  685.         UWORD i;
  686.         unsigned char ech;
  687.  
  688.         while(ech = *index++)
  689.         {
  690.           if(   !(ech>='a' && ech<='z')   // still a valid email char?
  691.              && !(ech>='A' && ech<='Z')
  692.              && !(ech>='0' && ech<='9')
  693.              && !(ech=='@' || ech=='.' || ech=='_' || ech=='-')) break;
  694.           length++;
  695.           if(ech=='@')                    // count '@'
  696.           {
  697.             if(*index=='{')               // is it an AmigaGuide attribute?
  698.             {
  699.               length--;                   //   exclude the '@'
  700.               break;                      //   the address is finished
  701.             }
  702.             atfound++;
  703.             atdot = 0;
  704.             continue;
  705.           }
  706.           if(ech=='.')                    // count '.'
  707.           {
  708.             dotfound++;
  709.             atdot++;
  710.             chardot = 0;
  711.             continue;
  712.           }
  713.           charcnt++;                      // one more char
  714.           chardot++;
  715.         }
  716.         if(   atfound==1                  // exactly one '@'
  717.            && dotfound>0                  // at least one '.' (domain.country)
  718.            && atdot>0                     //   this dot must be after the '@'
  719.            && chardot>=2 && chardot<=4    // domain must have two or three chars
  720.            && charcnt>6)                  // and we have also some chars
  721.         {
  722.           if(-1 == IDOS->FPuts(fh,"<a href=\"mailto:")) return(0);  // Generate email link
  723.           for(i=0;i<length;i++)
  724.           {
  725.             if(-1 == IDOS->FPutC(fh,buf[i])) return(0);
  726.           }
  727.           if(-1 == IDOS->FPuts(fh,"\">")) return(0);
  728.           for(;length;length--)
  729.           {
  730.             if(-1 == IDOS->FPutC(fh,*buf++)) return(0);
  731.           }
  732.           if(-1 == IDOS->FPuts(fh,"</a>")) return(0);
  733.           continue;
  734.         }
  735.         buf++;
  736.       }
  737.     }
  738.  
  739.     if(dolink)                            // internet link recognition
  740.     {
  741.       if(  (!IUtility->Strnicmp(buf-1,"ftp://"  ,6))    // ftp://... - Link ?
  742.          ||(!IUtility->Strnicmp(buf-1,"gopher:" ,7))    // gopher:... - Link ?
  743.          ||(!IUtility->Strnicmp(buf-1,"http://" ,7))    // http://... - Link ?
  744.          ||(!IUtility->Strnicmp(buf-1,"https://",8))    // https://... - Link ?
  745.          ||(!IUtility->Strnicmp(buf-1,"mailto:" ,7))    // mailto:... - Link ?
  746.          ||(!IUtility->Strnicmp(buf-1,"news:"   ,5))    // news:... - Link ?
  747.          ||(!IUtility->Strnicmp(buf-1,"nntp:"   ,5))    // nntp:... - Link ?
  748.          ||(!IUtility->Strnicmp(buf-1,"telnet:" ,7))    // telnet:... - Link ?
  749.          ||(!IUtility->Strnicmp(buf-1,"www."    ,4)))   // www. - Link?
  750.       {
  751.         STRPTR bufstart;
  752.  
  753.         if(-1 == IDOS->FPuts(fh,"<a href=\"")) return(0);
  754.  
  755.         if(!IUtility->Strnicmp(buf-1,"www.",4))
  756.           if(-1 == IDOS->FPuts(fh,"http://")) return(0);
  757.  
  758.         bufstart = --buf;
  759.         while(ch = *buf++)
  760.         {
  761.           if(' '==ch || '\n'==ch || ')'==ch || ('@'==ch && '{'==*buf)) break;
  762.           if(-1 == IDOS->FPutC(fh,ch)) return(0);
  763.         }
  764.         if(-1 == IDOS->FPuts(fh,"\">")) return(0);
  765.         for(;bufstart<buf-1;bufstart++)     // followed by a verbatim copy
  766.         {
  767.           if(-1 == IDOS->FPutC(fh,*bufstart)) return(0);
  768.         }
  769.         if(-1 == IDOS->FPuts(fh,"</a>")) return(0);
  770.       }
  771.     }
  772.  
  773.     if('@'==ch && '{'==*buf)              // AmigaGuide command?
  774.     {
  775.       buf++;                              // read the command?
  776.       for(;;)
  777.       {
  778.         if('\"' == *buf)                  // is it a link?
  779.         {
  780.           STRPTR link;
  781.           UWORD  linkpos=0;
  782.           BOOL   linkquot=0;
  783.  
  784.           buf++;                          // skip the quotation marks
  785.           link = buf;
  786.           while(*link && *link!='\"') link++;
  787.           if(!*link) return(0);
  788.           link++;
  789.           while(*link && (*link==' ' || *link==',' || *link=='\t')) link++;
  790.           if(!*link) return(0);
  791.           if(IUtility->Strnicmp(link,"link",4))
  792.           {                               // this is NO link command!
  793.             if(-1 == IDOS->FPuts(fh,"<u>")) return(0);
  794.             while((ch = *buf++) != '\"')
  795.               if(-1 == MyPutCh(fh,ch)) return(0);
  796.             if(-1 == IDOS->FPuts(fh,"</u>")) return(0);
  797.             buf = link;
  798.             while(*buf && *buf!=' ') buf++;
  799.             *buf++ = '\0';
  800.             if(!param.nowarn) printf("Line %ld: WARNING: '%s' command skipped!\n",linenr,link);
  801.             while(*buf && *buf!='}') buf++;
  802.             if(*buf =='}') buf++;
  803.             break;
  804.           }
  805.           link+=4;
  806.           while(*link && *link==' ') link++;
  807.           if(!*link) return(0);
  808.           if(*link == '\"')
  809.           {
  810.             link++;
  811.             linkquot=1;
  812.           }
  813.           while(*link && *link!='}')
  814.           {
  815.             ch = *link++;
  816.             if(ch=='\"' && linkquot) break;
  817.             if(ch==' ' && !linkquot) break;
  818.             if(ch>='A' && ch<='Z') ch+=32;
  819.             linkstr[linkpos++] = (ch==' ' || ch==':' ? '_' : ch);
  820.           }
  821.           while(*link && *link!='}') link++;
  822.           while(linkpos>0 && linkstr[linkpos-1] == '_') linkpos--;
  823.           if(linkstr[linkpos-1] == '\"') linkpos--;
  824.           linkstr[linkpos] = '\0';
  825.           if(!*link) return(0);
  826.           link++;
  827.           if(-1 == IDOS->FPuts(fh,"<a href=\"")) return(0);
  828.           if(param.linkadd)
  829.           {
  830.             if(-1 == IDOS->FPuts(fh,param.linkadd)) return(0);
  831.           }
  832.           if(-1 == IDOS->FPuts(fh,linkstr)) return(0);
  833.           if(param.msdos)
  834.           {
  835.             if(-1 == IDOS->FPuts(fh,".htm\">")) return(0);
  836.           }
  837.           else
  838.           {
  839.             if(-1 == IDOS->FPuts(fh,".html\">")) return(0);
  840.           }
  841.           while((ch = *buf++) != '\"')
  842.             if(-1 == MyPutCh(fh,ch)) return(0);
  843.           if(-1 == IDOS->FPuts(fh,"</a>")) return(0);
  844.           buf = link;
  845.           break;
  846.         }
  847.  
  848.         if(!IUtility->Strnicmp(buf,"b}",2))         // @{B}
  849.         {
  850.           if(-1 == IDOS->FPuts(fh,"<b>")) return(0);
  851.           buf += 2;
  852.           break;
  853.         }
  854.         if(!IUtility->Strnicmp(buf,"ub}",3))        // @{UB}
  855.         {
  856.           if(-1 == IDOS->FPuts(fh,"</b>")) return(0);
  857.           buf += 3;
  858.           break;
  859.         }
  860.  
  861.         if(!IUtility->Strnicmp(buf,"i}",2))         // @{I}
  862.         {
  863.           if(-1 == IDOS->FPuts(fh,"<i>")) return(0);
  864.           buf += 2;
  865.           break;
  866.         }
  867.         if(!IUtility->Strnicmp(buf,"ui}",3))        // @{UI}
  868.         {
  869.           if(-1 == IDOS->FPuts(fh,"</i>")) return(0);
  870.           buf += 3;
  871.           break;
  872.         }
  873.  
  874.         if(!IUtility->Strnicmp(buf,"u}",2))         // @{U}
  875.         {
  876.           if(-1 == IDOS->FPuts(fh,"<u>")) return(0);
  877.           buf += 2;
  878.           break;
  879.         }
  880.         if(!IUtility->Strnicmp(buf,"uu}",3))        // @{UU}
  881.         {
  882.           if(-1 == IDOS->FPuts(fh,"</u>")) return(0);
  883.           buf += 3;
  884.           break;
  885.         }
  886.         if(!IUtility->Strnicmp(buf,"code}",3))        // @{CODE}
  887.         {
  888.           if(-1 == IDOS->FPuts(fh,"<pre>")) return(0);
  889.           buf += 5;
  890.           break;
  891.         }
  892.         if(!IUtility->Strnicmp(buf,"body}",3))        // @{BODY}
  893.         {
  894.           if(-1 == IDOS->FPuts(fh,"</pre>")) return(0);
  895.           buf += 5;
  896.           break;
  897.         }
  898.         if(!IUtility->Strnicmp(buf,"line}",3))        // @{LINE}
  899.         {
  900.           if(-1 == IDOS->FPuts(fh,"<br>")) return(0);
  901.           buf += 5;
  902.           break;
  903.         }
  904.         if(!IUtility->Strnicmp(buf,"par}",3))        // @{PAR}
  905.         {
  906.           if(-1 == IDOS->FPuts(fh,"<p>")) return(0);
  907.           buf += 4;
  908.           break;
  909.         }
  910.         if(!IUtility->Strnicmp(buf,"plain}",3))        // @{PLAIN}
  911.         {
  912.           if(-1 == IDOS->FPuts(fh,"</b></i></u>")) return(0);
  913.           buf += 6;
  914.           break;
  915.         }
  916.         if(!IUtility->Strnicmp(buf,"jcenter}",3))        // @{JCENTER}
  917.         {
  918.           if(-1 == IDOS->FPuts(fh,"<p align=\"center\">")) return(0);
  919.           buf += 8;
  920.           break;
  921.         }
  922.         if(!IUtility->Strnicmp(buf,"jleft}",3))        // @{JLEFT}
  923.         {
  924.           if(-1 == IDOS->FPuts(fh,"<p align=\"left\">")) return(0);
  925.           buf += 6;
  926.           break;
  927.         }
  928.         if(!IUtility->Strnicmp(buf,"jright}",3))        // @{JRIGHT}
  929.         {
  930.           if(-1 == IDOS->FPuts(fh,"<p align=\"right\">")) return(0);
  931.           buf += 7;
  932.           break;
  933.         }
  934.  
  935.         if(!IUtility->Strnicmp(buf,"fg ",3))        // @{FG ...}
  936.         {
  937.           UWORD i=0;
  938.           buf += 3;
  939.  
  940.           while(*buf == ' ') buf++;
  941.  
  942.           while(agpens[i])
  943.           {
  944.             if(!IUtility->Strnicmp(buf,agpens[i],strlen(agpens[i])))
  945.             {
  946.               if(-1 == IDOS->FPrintf(fh,"<font color=\"%s\" class=\"%s\">",htmlpens[i],cssclass[i])) return(0);
  947.               buf += strlen(agpens[i]);
  948.               break;
  949.             }
  950.             i++;
  951.           }
  952.           if(agpens[i]) break;
  953.         }
  954.  
  955.         while(*buf && *buf!='}') buf++;   // Skip an unknown command!
  956.         buf++;
  957.         break;
  958.       }
  959.  
  960.     }
  961.     else
  962.       if(-1 == MyPutCh(fh,ch)) return(0); // Error!
  963.   }
  964.   return(1);
  965. }
  966. //<
  967.  
  968. //> NavBar()
  969. /*------------------------------------------------------------*
  970. *   NavBar()        Produces the navigation bar               *
  971. *     -> tfh   output file handle                             *
  972. *     -> enode node with link data                            *
  973. *     <-      Success                                         *
  974. */
  975. LONG NavBar(BPTR tfh, struct Entry *enode)
  976. {
  977.   short before = 0;
  978.   char main[100];
  979.  
  980.   for(;;)
  981.   {
  982.  
  983.     if(param.homeurl)
  984.     {
  985.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  986.       if(-1 == IDOS->FPrintf(tfh,"<a href=\"%s\">",param.homeurl)) break;
  987.       if(-1 == MyPuts(tfh,param.home)) break;
  988.       if(-1 == IDOS->FPuts(tfh,"</a>")) break;
  989.         before = 1;
  990.     }
  991.  
  992.  
  993.     if(enode->Count)            // main page does not have a TOC link
  994.     {
  995.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  996.  
  997. strcpy(main,param.linkadd);
  998.  
  999.       if(param.msdos)
  1000.       {
  1001.         strcat(main,"main.htm");
  1002.         if(-1 == IDOS->FPrintf(tfh,"<a href=\"%s\">",(*enode->TOC ? enode->TOC : main))) break;
  1003.       }
  1004.       else
  1005.       {
  1006.         strcat(main,"main.html");
  1007.         if(-1 == IDOS->FPrintf(tfh,"<a href=\"%s\">",(*enode->TOC ? enode->TOC : main))) break;
  1008.       }
  1009.       if(-1 == MyPuts(tfh,param.toc)) break;
  1010.       if(-1 == IDOS->FPuts(tfh,"</a>")) break;
  1011.       before = 1;
  1012.     }
  1013.     else if(param.showall)
  1014.     {
  1015.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1016.       if(-1 == MyPuts(tfh,param.toc)) break;
  1017.       before = 1;
  1018.     }
  1019.  
  1020.     if(*enode->Index)
  1021.     {
  1022.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1023.       if(-1 == IDOS->FPrintf(tfh,"<a href=\"%s\">",enode->Index)) break;
  1024.       if(-1 == MyPuts(tfh,param.index)) break;
  1025.       if(-1 == IDOS->FPuts(tfh,"</a>")) break;
  1026.       before = 1;
  1027.     }
  1028.     else if(*Index)
  1029.     {
  1030.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1031.       if(-1 == IDOS->FPrintf(tfh,"<a href=\"%s\">",Index)) break;
  1032.       if(-1 == MyPuts(tfh,param.index)) break;
  1033.       if(-1 == IDOS->FPuts(tfh,"</a>")) break;
  1034.       before = 1;
  1035.     }
  1036.     else if(param.showall)
  1037.     {
  1038.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1039.       if(-1 == MyPuts(tfh,param.index)) break;
  1040.       before = 1;
  1041.     }
  1042.  
  1043.     if(*enode->Help)
  1044.     {
  1045.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1046.       if(-1 == IDOS->FPrintf(tfh,"<a href=\"%s\">",enode->Help)) break;
  1047.       if(-1 == MyPuts(tfh,param.help)) break;
  1048.       if(-1 == IDOS->FPuts(tfh,"</a>")) break;
  1049.       before = 1;
  1050.     }
  1051.     else if(*Help)
  1052.     {
  1053.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1054.       if(-1 == IDOS->FPrintf(tfh,"<a href=\"%s\">",Help)) break;
  1055.       if(-1 == MyPuts(tfh,param.help)) break;
  1056.       if(-1 == IDOS->FPuts(tfh,"</a>")) break;
  1057.       before = 1;
  1058.     }
  1059.     else if(param.showall)
  1060.     {
  1061.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1062. //      if(-1 == IDOS->FPrintf(tfh,"<a href=\"http://www.unsatisfactorysoftware.co.uk/guideml/help.guide/main.html\">",Help)) break;
  1063.       if(-1 == MyPuts(tfh,param.help)) break;
  1064. //      if(-1 == IDOS->FPuts(tfh,"</a>")) break;
  1065.       before = 1;
  1066.     }
  1067.  
  1068.     if(param.retrace)
  1069.     {
  1070.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1071.       if(-1 == MyPuts(tfh,"<a href=\"javascript:window.history.go(-1)\">")) break;
  1072.       if(-1 == MyPuts(tfh,param.retrace)) break;
  1073.       if(-1 == IDOS->FPuts(tfh,"</a>")) break;
  1074.       before = 1;
  1075.     }
  1076.  
  1077.     if(*enode->Prev)
  1078.     {
  1079.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1080.       if(-1 == IDOS->FPrintf(tfh,"<a href=\"%s\">",enode->Prev)) break;
  1081.       if(-1 == MyPuts(tfh,param.prev)) break;
  1082.       if(-1 == IDOS->FPuts(tfh,"</a>")) break;
  1083.       before = 1;
  1084.     }
  1085.     else
  1086.     {
  1087.       struct Entry *pred = (struct Entry *)enode->link.mln_Pred;
  1088.       if(pred->link.mln_Pred)
  1089.       {
  1090.         if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1091.         if(-1 == IDOS->FPrintf(tfh,"<a href=\"%s\">",pred->Node)) break;
  1092.         if(-1 == MyPuts(tfh,param.prev)) break;
  1093.         if(-1 == IDOS->FPuts(tfh,"</a>")) break;
  1094.         before = 1;
  1095.       }
  1096.       else if(param.showall)
  1097.       {
  1098.         if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1099.         if(-1 == MyPuts(tfh,param.prev)) break;
  1100.         before = 1;
  1101.       }
  1102.  
  1103.     }
  1104.  
  1105.     if(*enode->Next)
  1106.     {
  1107.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1108.       if(-1 == IDOS->FPrintf(tfh,"<a href=\"%s\">",enode->Next)) break;
  1109.       if(-1 == MyPuts(tfh,param.next)) break;
  1110.       if(-1 == IDOS->FPuts(tfh,"</a>")) break;
  1111.       before = 1;
  1112.     }
  1113.     else
  1114.     {
  1115.       struct Entry *next = (struct Entry *)enode->link.mln_Succ;
  1116.       if(next->link.mln_Succ)
  1117.       {
  1118.         if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1119.         if(-1 == IDOS->FPrintf(tfh,"<a href=\"%s\">",next->Node)) break;
  1120.         if(-1 == MyPuts(tfh,param.next)) break;
  1121.         if(-1 == IDOS->FPuts(tfh,"</a>")) break;
  1122.         before = 1;
  1123.       }
  1124.       else if(param.showall)
  1125.       {
  1126.         if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1127.         if(-1 == MyPuts(tfh,param.next)) break;
  1128.         before = 1;
  1129.       }
  1130.  
  1131.     }
  1132.     if(param.findurl)
  1133.     {
  1134.       if(before) if(-1 == MyPuts(tfh,param.bar)) break;
  1135.       if(-1 == IDOS->FPrintf(tfh,"<a href=\"%s\">",param.findurl)) break;
  1136.       if(-1 == MyPuts(tfh,param.find)) break;
  1137.       if(-1 == IDOS->FPuts(tfh,"</a>")) break;
  1138.       before = 1;
  1139.     }
  1140.  
  1141.  
  1142.     if(-1 == IDOS->FPutC(tfh,'\n')) break;
  1143.     return(1);                            // ALL OK
  1144.   }
  1145.   return(0);                              // ERROR
  1146. }
  1147. //<
  1148.  
  1149. //> MozNavBar()
  1150. /*--------------------------------------------------------------------*
  1151. *   MozNavBar() Produces a Mozilla-compatible site navigation bar     *
  1152. *     -> tfh   output file handle                                     *
  1153. *     -> enode node with link data                                    *
  1154. *     <-      Success                                                 *
  1155. */
  1156. LONG MozNavBar(BPTR tfh, struct Entry *enode)
  1157. {
  1158.   short before = 0;
  1159.  
  1160.   for(;;)
  1161.   {
  1162.     if(enode->Count)            // main page does not have a TOC link
  1163.     {
  1164.       if(param.msdos)
  1165.       {
  1166.         if(-1 == IDOS->FPrintf(tfh,"<link rel=\"up\" href=\"%s\" title=\"%s\" />\n",(*enode->TOC ? enode->TOC : "main.htm"),textlabs.toc)) break;
  1167.       }
  1168.       else
  1169.       {
  1170.         if(-1 == IDOS->FPrintf(tfh,"<link rel=\"up\" href=\"%s\" title=\"%s\" />\n",(*enode->TOC ? enode->TOC : "main.html"),textlabs.toc)) break;
  1171.       }
  1172.     }
  1173.  
  1174.     if(*enode->Index)
  1175.     {
  1176.       if(-1 == IDOS->FPrintf(tfh,"<link rel=\"index\" href=\"%s\" title=\"%s\" />\n",enode->Index,textlabs.index)) break;
  1177.     }
  1178.     else if(*Index)
  1179.     {
  1180.       if(-1 == IDOS->FPrintf(tfh,"<link rel=\"index\" href=\"%s\" title=\"%s\" />\n",Index,param.index)) break;
  1181.     }
  1182.  
  1183.     if(*enode->Prev)
  1184.     {
  1185.       if(-1 == IDOS->FPrintf(tfh,"<link rel=\"previous\" href=\"%s\" title=\"%s\" />\n",enode->Prev,textlabs.prev)) break;
  1186.     }
  1187.     else
  1188.     {
  1189.       struct Entry *pred = (struct Entry *)enode->link.mln_Pred;
  1190.       if(pred->link.mln_Pred)
  1191.       {
  1192.         if(-1 == IDOS->FPrintf(tfh,"<link rel=\"previous\" href=\"%s\" title=\"%s\" />\n",pred->Node,textlabs.prev)) break;
  1193.       }
  1194.     }
  1195.  
  1196.     if(*enode->Next)
  1197.     {
  1198.       if(-1 == IDOS->FPrintf(tfh,"<link rel=\"next\" href=\"%s\" title=\"%s\" />\n",enode->Next,textlabs.next)) break;
  1199.     }
  1200.     else
  1201.     {
  1202.       struct Entry *next = (struct Entry *)enode->link.mln_Succ;
  1203.       if(next->link.mln_Succ)
  1204.       {
  1205.         if(-1 == IDOS->FPrintf(tfh,"<link rel=\"next\" href=\"%s\" title=\"%s\" />\n",next->Node,textlabs.next)) break;
  1206.       }
  1207.     }
  1208.  
  1209.     if(*enode->Help)
  1210.     {
  1211.       if(-1 == IDOS->FPrintf(tfh,"<link rel=\"help\" href=\"%s\" title=\"%s\" />\n",enode->Help,textlabs.help)) break;
  1212.     }
  1213.     else if(*Help)
  1214.     {
  1215.       if(-1 == IDOS->FPrintf(tfh,"<link rel=\"help\" href=\"%s\" title=\"%s\" />\n",Help,textlabs.help)) break;
  1216.     }
  1217.      else
  1218.      {
  1219.       if(-1 == IDOS->FPuts(tfh,"<link rel=\"help\" href=\"http://www.unsatisfactorysoftware.co.uk/guideml/help.guide/main.html\" title=\"AmigaGuide Help\" />\n")) break;
  1220.      }
  1221.  
  1222.     if(param.homeurl)
  1223.     {
  1224.       if(-1 == IDOS->FPrintf(tfh,"<link rel=\"top\" href=\"%s\" title=\"%s\" />\n",param.homeurl,textlabs.home)) break;
  1225.     }
  1226.  
  1227.     if(param.findurl)
  1228.     {
  1229.       if(-1 == IDOS->FPrintf(tfh,"<link rel=\"search\" href=\"%s\" title=\"%s\" />\n",param.findurl,textlabs.find)) break;
  1230.     }
  1231.  
  1232.       if(-1 == IDOS->FPuts(tfh,"<link rel=\"GuideML\" href=\"http://www.unsatisfactorysoftware.co.uk/\" title=\"Unsatisfactory Software\" />\n")) break;
  1233.  
  1234.  
  1235. //    if(-1 == IDOS->FPutC(tfh,'\n')) break;
  1236.     return(1);                            // ALL OK
  1237.   }
  1238.   return(0);                              // ERROR
  1239. }
  1240. //<
  1241.  
  1242. //> Convert()
  1243. /*------------------------------------------------------------*
  1244. *   Convert()       Reads guide and creates HTML files        *
  1245. *     -> fh   input file handle                               *
  1246. *     <-      Success                                         *
  1247. */
  1248. LONG Convert(BPTR fh)
  1249. {
  1250.   STRPTR buffer = IExec->AllocVec(LINELEN,MEMF_ANY);     // allocate line buffer
  1251.   char copyright[100] = "\0";
  1252.   char author[100] = "\0";
  1253.   char version[100] = "\0";
  1254.   char master[100] = "\0";
  1255.   char database[100] = "\0";
  1256.   char keywords[100] = "\0";
  1257.   char description[200] = "\0";
  1258.   STRPTR node, title, line;
  1259.   char nodename[100];
  1260.   char filename[100];
  1261.   BPTR tfh = (BPTR)NULL;
  1262.   ULONG linenr = 0;
  1263.   short firstpage = 1;
  1264.   struct Entry *enode = (struct Entry *)entries.mlh_Head;
  1265.   register UWORD donavbar = !param.nonavbar;
  1266.   LONG wrap = 0;
  1267.   long mode;
  1268.  
  1269.   if(param.wordwrap || param.smartwrap) wrap = 1;
  1270.  
  1271.   if(!buffer) return(0);
  1272.  
  1273.   if(!wb) IDOS->PutStr("Converting into HTML\n");
  1274.  
  1275.    /* search for @node */
  1276.   do
  1277.   {
  1278.     linenr++;
  1279.     if(IDOS->FGets(fh,buffer,LINELEN) == NULL) goto Done;
  1280.  
  1281.    if(!param.noauto)
  1282.    {
  1283.     if(IUtility->Strnicmp(buffer,"@wordwrap",9)==0)
  1284.     {
  1285.     if(!wb) IDOS->PutStr("@wordwrap detected!\n");
  1286.      param.wordwrap = 1;
  1287.      wrap = 1;
  1288.      }
  1289.     if(IUtility->Strnicmp(buffer,"@smartwrap",10)==0)
  1290.     {
  1291.     if(!wb) IDOS->PutStr("@smartwrap detected!\n");
  1292.      param.smartwrap = 1;
  1293.      wrap = 1;
  1294.      }
  1295.    }
  1296.  
  1297.    // the below would be seriously better off as subroutines...
  1298.  
  1299.      if(IUtility->Strnicmp(buffer,"@(c) ",5)==0)
  1300.      {
  1301.        line = buffer+5;
  1302.       while(*line == ' ') line++;   // Skip spaces
  1303.       if(*line == '\"') line++;     // Skip quotation mark
  1304.       title = line;
  1305.       while(*line != '\n') line++;  // search EOL
  1306.       do line--; while(*line==' '); // skip trailing spaces
  1307.       if(*line == '\"') line--;     // skip trailing quotation mark
  1308.       *++line = '\0';               // terminate the line
  1309.       strcpy(copyright,title);
  1310.     }
  1311.  
  1312.      if(IUtility->Strnicmp(buffer,"@author ",8)==0)
  1313.      {
  1314.        line = buffer+8;
  1315.       while(*line == ' ') line++;   // Skip spaces
  1316.       if(*line == '\"') line++;     // Skip quotation mark
  1317.       title = line;
  1318.       while(*line != '\n') line++;  // search EOL
  1319.       do line--; while(*line==' '); // skip trailing spaces
  1320.       if(*line == '\"') line--;     // skip trailing quotation mark
  1321.       *++line = '\0';               // terminate the line
  1322.       strcpy(author,title);
  1323.      }
  1324.  
  1325.      if(IUtility->Strnicmp(buffer,"@$ver:",6)==0)
  1326.      {
  1327.             line = buffer+6;
  1328.       while(*line == ' ') line++;   // Skip spaces
  1329.       if(*line == '\"') line++;     // Skip quotation mark
  1330.       title = line;
  1331.       while(*line != '\n') line++;  // search EOL
  1332.       do line--; while(*line==' '); // skip trailing spaces
  1333.       if(*line == '\"') line--;     // skip trailing quotation mark
  1334.       *++line = '\0';               // terminate the line
  1335.       strcpy(version,title);
  1336.     }
  1337.  
  1338.      if(IUtility->Strnicmp(buffer,"@database ",10)==0)
  1339.      {
  1340.        line = buffer+10;
  1341.       while(*line == ' ') line++;   // Skip spaces
  1342.       if(*line == '\"') line++;     // Skip quotation mark
  1343.       title = line;
  1344.       while(*line != '\n') line++;  // search EOL
  1345.       do line--; while(*line==' '); // skip trailing spaces
  1346.       if(*line == '\"') line--;     // skip trailing quotation mark
  1347.       *++line = '\0';               // terminate the line
  1348.       strcpy(database,title);
  1349.     }
  1350.  
  1351.      if(IUtility->Strnicmp(buffer,"@master ",8)==0)
  1352.      {
  1353.             line = buffer+8;
  1354.       while(*line == ' ') line++;   // Skip spaces
  1355.       if(*line == '\"') line++;     // Skip quotation mark
  1356.       title = line;
  1357.       while(*line != '\n') line++;  // search EOL
  1358.       do line--; while(*line==' '); // skip trailing spaces
  1359.       if(*line == '\"') line--;     // skip trailing quotation mark
  1360.       *++line = '\0';               // terminate the line
  1361.       strcpy(master,title);
  1362.     }
  1363.  
  1364.      if(IUtility->Strnicmp(buffer,"@keywords ",10)==0)
  1365.      {
  1366.             line = buffer+10;
  1367.       while(*line == ' ') line++;   // Skip spaces
  1368.       if(*line == '\"') line++;     // Skip quotation mark
  1369.       title = line;
  1370.       while(*line != '\n') line++;  // search EOL
  1371.       do line--; while(*line==' '); // skip trailing spaces
  1372.       if(*line == '\"') line--;     // skip trailing quotation mark
  1373.       *++line = '\0';               // terminate the line
  1374.      strcpy(keywords,title);
  1375.     }
  1376.  
  1377.      if(IUtility->Strnicmp(buffer,"@description ",13)==0)
  1378.      {
  1379.             line = buffer+13;
  1380.       while(*line == ' ') line++;   // Skip spaces
  1381.       if(*line == '\"') line++;     // Skip quotation mark
  1382.       title = line;
  1383.       while(*line != '\n') line++;  // search EOL
  1384.       do line--; while(*line==' '); // skip trailing spaces
  1385.       if(*line == '\"') line--;     // skip trailing quotation mark
  1386.       *++line = '\0';               // terminate the line
  1387.      strcpy(description,title);
  1388.     }
  1389.  
  1390.   }
  1391.   while(IUtility->Strnicmp(buffer,"@node ",strlen("@node ")));
  1392.  
  1393.    /* and go... */
  1394.   for(;;)
  1395.   {
  1396.     if(IExec->SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) goto ErrorBrk;
  1397.  
  1398.      /* search the node name */
  1399.     node = buffer+strlen("@node ");
  1400.     while(*node == ' ') node++;     // skip leading spaces
  1401.     if(*node == '\"')
  1402.     {                               // Quote Mode
  1403.       node++;
  1404.       line = node;
  1405.       while(*line!='\"' && *line!='\n')
  1406.       {
  1407.         if(*line==' ' || *line==':') *line='_';  // space -> '_'
  1408.         line++;
  1409.       }
  1410.       *line++ = '\0';
  1411.     }
  1412.     else
  1413.     {
  1414.       line = node;
  1415.       while(*line!=' ' && *line!='\n')
  1416.       {
  1417.         if(*line==':') *line='/';               // ':' -> '_'
  1418.         line++;
  1419.       }
  1420.       *line++ = '\0';
  1421.     }
  1422.  
  1423.      /* search node title */
  1424.     if(*line == '\0' || *line == '\n')
  1425.         {
  1426.       title = line;                 // Node does not have a title
  1427.         if(*enode->Titl)
  1428.             {
  1429.                 title = enode->Titl;
  1430.  
  1431. //printf("%s\n",title);
  1432.  
  1433.             }
  1434.         }
  1435.     else
  1436.     {
  1437.       while(*line == ' ') line++;   // Skip spaces
  1438.       if(*line == '\"') line++;     // Skip quotation mark
  1439.       title = line;
  1440.       while(*line != '\n') line++;  // search EOL
  1441.       do line--; while(*line==' '); // skip trailing spaces
  1442.       if(*line == '\"') line--;     // skip trailing quotation mark
  1443.       *++line = '\0';               // terminate the line
  1444.     }
  1445.  
  1446. //    strlwr(node);                   // node name to lowercase
  1447.  
  1448.     strcpy(nodename,node);
  1449.  
  1450.         if(param.msdos)
  1451.         {
  1452.               strcat(nodename,".htm");
  1453.         }
  1454.         else
  1455.         {
  1456.               strcat(nodename,".html");
  1457.         }
  1458.  
  1459.     if(param.singlefile)
  1460.     {
  1461.         if(IUtility->Strnicmp(nodename,"main",4) == 0)
  1462.         {
  1463.             mode = MODE_NEWFILE;
  1464.         }
  1465.         else
  1466.         {
  1467.             mode = MODE_OLDFILE;
  1468.         }
  1469.  
  1470.         strcpy(filename,"main.html");        
  1471.     }
  1472.     else
  1473.     {
  1474.         mode = MODE_NEWFILE;
  1475.  
  1476.         strcpy(filename,nodename);
  1477.     }
  1478.  
  1479.  
  1480.     if(tfh = IDOS->Open(filename,mode))
  1481.     {
  1482.  
  1483.         if(param.singlefile)
  1484.         {
  1485.             IDOS->Seek(tfh,0,OFFSET_END);
  1486.         }
  1487.  
  1488.  
  1489.       if(param.verbatim) printf("Creating page '%s' (Title: '%s')\n",nodename,title);
  1490.  
  1491. if(((param.singlefile & firstpage) | (!param.singlefile)) & (!param.nohtml))
  1492. //if(!param.nohtml)
  1493. {
  1494.       if(-1 == IDOS->FPuts(tfh,"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"\n\"http://www.w3.org/TR/REC-html40/loose.dtd\">\n<html>\n<head>\n<title>")) goto ErrorFile;
  1495.       if(-1 == MyPuts(tfh,title)) goto ErrorFile;
  1496.       if(-1 == IDOS->FPuts(tfh,"</title>\n"
  1497.                          "<meta name=\"Generator\" content=\"GuideML " VERSIONSTR " (http://www.unsatisfactorysoftware.co.uk/guideml/)\">\n"
  1498.                          "<meta http-equiv=\"Content-Type\" content=\"text/html\">\n")) goto ErrorFile;
  1499.         // start custom meta
  1500.         if(strlen(copyright) > 2)
  1501.         {
  1502.         if(-1 == IDOS->FPuts(tfh,"<meta name=\"Copyright\" content=\"")) goto ErrorFile;
  1503.         if(-1 == MyPuts(tfh,copyright)) goto ErrorFile;
  1504.         if(-1 == IDOS->FPuts(tfh,"\">\n")) goto ErrorFile;
  1505.         }
  1506.         // end custom meta
  1507.         // start custom meta
  1508.         if(strlen(author) > 2)
  1509.         {
  1510.         if(-1 == IDOS->FPuts(tfh,"<meta name=\"Author\" content=\"")) goto ErrorFile;
  1511.         if(-1 == MyPuts(tfh,author)) goto ErrorFile;
  1512.         if(-1 == IDOS->FPuts(tfh,"\">\n")) goto ErrorFile;
  1513.         }
  1514.         // end custom meta
  1515.         // start custom meta
  1516.         if(strlen(version) > 2)
  1517.         {
  1518.         if(-1 == IDOS->FPuts(tfh,"<meta name=\"Version\" content=\"")) goto ErrorFile;
  1519.         if(-1 == MyPuts(tfh,version)) goto ErrorFile;
  1520.         if(-1 == IDOS->FPuts(tfh,"\">\n")) goto ErrorFile;
  1521.         }
  1522.         // end custom meta
  1523.         // start custom meta
  1524.         if(strlen(database) > 2)
  1525.         {
  1526.         if(-1 == IDOS->FPuts(tfh,"<meta name=\"Database\" content=\"")) goto ErrorFile;
  1527.         if(-1 == MyPuts(tfh,database)) goto ErrorFile;
  1528.         if(-1 == IDOS->FPuts(tfh,"\">\n")) goto ErrorFile;
  1529.         }
  1530.         // end custom meta
  1531.         // start custom meta
  1532.         if(strlen(master) > 2)
  1533.         {
  1534.         if(-1 == IDOS->FPuts(tfh,"<meta name=\"Master\" content=\"")) goto ErrorFile;
  1535.         if(-1 == MyPuts(tfh,master)) goto ErrorFile;
  1536.         if(-1 == IDOS->FPuts(tfh,"\">\n")) goto ErrorFile;
  1537.         }
  1538.         // end custom meta
  1539.         // start custom meta
  1540.         if(strlen(keywords) > 2)
  1541.         {
  1542.             if(-1 == IDOS->FPuts(tfh,"<meta name=\"Keywords\" content=\"")) goto ErrorFile;
  1543.             if(-1 == MyPuts(tfh,keywords)) goto ErrorFile;
  1544.             if(-1 == IDOS->FPuts(tfh,"\">\n")) goto ErrorFile;
  1545.         }
  1546.         // end custom meta
  1547.         // start custom meta
  1548.         if(strlen(description) > 2)
  1549.         {
  1550.             if(-1 == IDOS->FPuts(tfh,"<meta name=\"Description\" content=\"")) goto ErrorFile;
  1551.             if(-1 == MyPuts(tfh,description)) goto ErrorFile;
  1552.             if(-1 == IDOS->FPuts(tfh,"\">\n")) goto ErrorFile;
  1553.         }
  1554.         // end custom meta
  1555.  
  1556.         if(param.cssurl)
  1557.         {
  1558.             if(-1 == IDOS->FPuts(tfh,"<link rel=\"stylesheet\" href=\"")) goto ErrorFile;
  1559.             if(-1 == MyPuts(tfh,param.cssurl)) goto ErrorFile;
  1560.             if(-1 == IDOS->FPuts(tfh,"\" type=\"text/css\">")) goto ErrorFile;
  1561.         }
  1562.  
  1563.         if(!param.nomoznav)
  1564.         {
  1565.       if(!MozNavBar(tfh,enode)) goto ErrorFile;
  1566.       }
  1567.  
  1568.  
  1569.         if(-1 == IDOS->FPuts(tfh,"</head>\n<body")) goto ErrorFile;
  1570.  
  1571.       if(param.bodyext)
  1572.       {
  1573.         if(-1 == IDOS->FPutC(tfh,' ')) goto ErrorFile;
  1574.         if(-1 == MyPuts(tfh,param.bodyext)) goto ErrorFile;
  1575.       }
  1576.       if(-1 == IDOS->FPuts(tfh,">\n")) goto ErrorFile;
  1577.  
  1578. }
  1579.  
  1580.         if(param.singlefile)
  1581.         {
  1582.             if(-1 == IDOS->FPuts(tfh,"<a name=\"")) goto ErrorFile;
  1583.             if(-1 == MyPuts(tfh,nodename)) goto ErrorFile;
  1584.             if(-1 == IDOS->FPuts(tfh,"\">")) goto ErrorFile;
  1585.               if(-1 == MyPuts(tfh,title)) goto ErrorFile;
  1586.             if(-1 == IDOS->FPuts(tfh,"</a><p>")) goto ErrorFile;
  1587.             firstpage=0;
  1588.  
  1589.         }
  1590.  
  1591.       if(param.htmltoptxt)
  1592.       {
  1593.         if(-1 == IDOS->FPutC(tfh,' ')) goto ErrorFile;
  1594.         if(-1 == MyPuts(tfh,param.htmltoptxt)) goto ErrorFile;
  1595.       }
  1596.       if(param.htmlheadf)
  1597.       {
  1598.         if(-1 == IDOS->FPutC(tfh,' ')) goto ErrorFile;
  1599.         if(-1 == MyPuts(tfh,(STRPTR)htmltop)) goto ErrorFile;
  1600.       }
  1601.  
  1602.         if(donavbar)
  1603.         {
  1604.       if(!NavBar(tfh,enode)) goto ErrorFile;
  1605.       if(-1 == IDOS->FPuts(tfh,"<hr>\n")) goto ErrorFile;
  1606.       }
  1607.  
  1608.         if(!wrap)
  1609.         {
  1610.           if(-1 == IDOS->FPuts(tfh,"<pre>\n")) goto ErrorFile;
  1611.         }
  1612.         else
  1613.         {
  1614.             if(!param.varwidth)
  1615.           {
  1616.               if(-1 == IDOS->FPuts(tfh,"<tt>\n")) goto ErrorFile;
  1617.           }
  1618.         }
  1619.  
  1620.       for(;;)
  1621.       {
  1622.         linenr++;
  1623.         if(IDOS->FGets(fh,buffer,LINELEN) == NULL) goto ErrorEOF;
  1624.  
  1625. // TEMPORARY FOR TEST PORPOISES!
  1626. //printf("%s\n",buffer);
  1627.  
  1628.         if(buffer[0]=='@' && buffer[1]!='{')    // is it an AmigaGuide command
  1629.         {
  1630.           if(!IUtility->Strnicmp(buffer,"@node ",strlen("@node "))) break;
  1631.           if(!IUtility->Strnicmp(buffer,"@endnode",strlen("@endnode"))) break;
  1632.           continue;                           // unknown command
  1633.         }
  1634.  
  1635.         if(!ConvLine(tfh,buffer,linenr))
  1636.         {
  1637.             sprintf(temp,"Line %ld: Couldn't convert!\n",linenr);
  1638.           err(temp,"OK",0);
  1639.           goto Error;
  1640.         }
  1641.                 if(param.wordwrap)
  1642.                 {
  1643.                       if(-1 == IDOS->FPuts(tfh,"<br>")) return(0);
  1644.                 }
  1645.  
  1646.       }
  1647.  
  1648.         if(!wrap)
  1649.         {
  1650.           if(-1 == IDOS->FPuts(tfh,"</pre>\n")) goto ErrorFile;
  1651.         }
  1652.         else
  1653.         {
  1654.             if(!param.varwidth)
  1655.           {
  1656.               if(-1 == IDOS->FPuts(tfh,"</tt>\n")) goto ErrorFile;
  1657.             }
  1658.         }
  1659.  
  1660.  
  1661.     if(param.singlefile)
  1662.     {
  1663.         if(-1 == IDOS->FPuts(tfh,"<hr>\n")) goto ErrorFile;
  1664.     }
  1665.     else
  1666.     {
  1667.  
  1668.       if(param.footer)
  1669.       {
  1670.         if(-1 == IDOS->FPuts(tfh,"<hr>\n")) goto ErrorFile;
  1671.         if(donavbar)
  1672.             {
  1673.             if(!NavBar(tfh,enode)) goto ErrorFile;
  1674.             }
  1675.       }
  1676.  
  1677.       if(param.htmlbottxt)
  1678.       {
  1679.         if(-1 == IDOS->FPutC(tfh,' ')) goto ErrorFile;
  1680.         if(-1 == MyPuts(tfh,param.htmlbottxt)) goto ErrorFile;
  1681.       }
  1682.       else if(param.htmlfootf)
  1683.       {
  1684.         if(-1 == IDOS->FPutC(tfh,' ')) goto ErrorFile;
  1685.         if(-1 == MyPuts(tfh,(STRPTR)htmlbot)) goto ErrorFile;
  1686.       }
  1687.         else
  1688.         {
  1689.           if(firstpage)
  1690.           {
  1691.             firstpage=0;
  1692.             if(-1 == IDOS->FPuts(tfh,"<hr>\n<address>Converted using <a href=\"http://www.unsatisfactorysoftware.co.uk/guideml/\">GuideML "VERSIONSTR "</a></address>\n")) goto ErrorFile;
  1693.           }
  1694.       }
  1695.  
  1696.     if(!param.nohtml)
  1697.     {
  1698.       if(-1 == IDOS->FPuts(tfh,"</body>\n</html>\n")) goto ErrorFile;
  1699.     }
  1700. }
  1701.  
  1702.       enode = (struct Entry *)enode->link.mln_Succ;
  1703.       IDOS->Close(tfh);
  1704.       tfh = (BPTR)NULL;
  1705.     }
  1706.     else
  1707.     {
  1708. sprintf(temp,"Line %ld: Couldn't open %s for writing!\n",linenr,nodename);
  1709.       err(temp,"OK",0);
  1710.       goto Error;
  1711.     }
  1712.  
  1713.     while(IUtility->Strnicmp(buffer,"@node ",strlen("@node ")))
  1714.     {
  1715.       linenr++;
  1716.       if(IDOS->FGets(fh,buffer,LINELEN) == NULL) goto Done;
  1717.     }
  1718.   }
  1719.  
  1720. Done:
  1721.  
  1722.     if(param.singlefile)
  1723.     {
  1724.  
  1725.     if(tfh = IDOS->Open(filename,MODE_OLDFILE))
  1726.     {
  1727.         IDOS->Seek(tfh,0,OFFSET_END);
  1728.  
  1729.       if(param.footer)
  1730.       {
  1731.         if(donavbar)
  1732.             {
  1733.             if(!NavBar(tfh,enode)) goto ErrorFile;
  1734.             }
  1735.       }
  1736.  
  1737.       if(param.htmlbottxt)
  1738.       {
  1739.         if(-1 == IDOS->FPutC(tfh,' ')) goto ErrorFile;
  1740.         if(-1 == MyPuts(tfh,param.htmlbottxt)) goto ErrorFile;
  1741.       }
  1742.       else if(param.htmlfootf)
  1743.       {
  1744.         if(-1 == IDOS->FPutC(tfh,' ')) goto ErrorFile;
  1745.         if(-1 == MyPuts(tfh,(STRPTR)htmlbot)) goto ErrorFile;
  1746.       }
  1747.         else
  1748.         {
  1749.             if(-1 == IDOS->FPuts(tfh,"<address>Converted using <a href=\"http://www.unsatisfactorysoftware.co.uk/guideml/\">GuideML "VERSIONSTR "</a></address>\n")) goto ErrorFile;
  1750.       }
  1751.  
  1752. if(!param.nohtml)
  1753.     {
  1754.       if(-1 == IDOS->FPuts(tfh,"</body>\n</html>\n")) goto ErrorFile;
  1755.     }
  1756.  
  1757.       IDOS->Close(tfh);
  1758.       tfh = (BPTR)NULL;
  1759.  
  1760.     }
  1761. }
  1762.  
  1763.  
  1764.   IExec->FreeVec(buffer);
  1765.   return(1);
  1766.  
  1767. ErrorBrk:
  1768. sprintf(temp,"Line %ld: <CTRL-C> pressed!\n",linenr);
  1769.   err(temp,"OK",0);
  1770.   goto Error;
  1771. ErrorFile:
  1772. sprintf(temp,"Line %ld: Error writing file!\n",linenr);
  1773.   err(temp,"OK",0);
  1774.   goto Error;
  1775. ErrorEOF:
  1776. sprintf(temp,"Line %ld: Unexpected EOF!\n",linenr);
  1777.   err(temp,"OK",0);
  1778. Error:
  1779.   if(tfh) IDOS->Close(tfh);
  1780.   IExec->FreeVec(buffer);
  1781.   return(0);
  1782. }
  1783. //<
  1784. //> PreScan()
  1785. /*------------------------------------------------------------*
  1786. *   PreScan()       Scans the AmigaGuide file                 *
  1787. *     -> fh   input file handle                               *
  1788. *     <-      Success                                         *
  1789. */
  1790. LONG PreScan(BPTR fh)
  1791. {
  1792.   STRPTR buffer = IExec->AllocVec(LINELEN,MEMF_ANY);     // allocate line buffer
  1793.   STRPTR parse;
  1794.   STRPTR title;
  1795.   ULONG linenr  = 0;
  1796.   ULONG nodectr = 0;
  1797.   struct Entry *currentry = NULL;
  1798.  
  1799.   if(!buffer) return(0);
  1800.  
  1801.   if(!wb) IDOS->PutStr("Scanning AmigaGuide document\n");
  1802.    /* Is it an AmigaGuide document ? */
  1803.   linenr++;
  1804.   if(NULL == IDOS->FGets(fh,buffer,LINELEN)) goto ErrorEOF;
  1805.   if(IUtility->Strnicmp(buffer,"@database",strlen("@database")))
  1806.   {
  1807.     err("This is not a valid AmigaGuide file!","OK",0);
  1808.     goto Error;
  1809.   }
  1810.  
  1811.    /* Search for commands */
  1812.   for(;;)
  1813.   {
  1814.     if(IExec->SetSignal(0L,SIGBREAKF_CTRL_C) & SIGBREAKF_CTRL_C) goto ErrorBrk;
  1815.     linenr++;
  1816.     if(!IDOS->FGets(fh,buffer,LINELEN)) break;      // Scan all lines
  1817.     if(buffer[0]!='@') continue;              // no command line
  1818.     if(buffer[1]=='{') continue;              // a text command at first column?
  1819.  
  1820.     parse = buffer+1;
  1821.  
  1822.     if(!IUtility->Strnicmp(parse,"node ",strlen("node ")))      // @node <name>
  1823.     {
  1824.       if(currentry) IExec->AddTail((struct List *)&entries,(struct Node *)currentry);
  1825.       currentry = IExec->AllocVec(sizeof(struct Entry),MEMF_ANY|MEMF_CLEAR);
  1826.       if(!currentry) goto ErrorMem;
  1827.       currentry->Count = nodectr++;
  1828.       CopyLink(parse+strlen("node "), currentry->Node);
  1829.     }
  1830.  
  1831.     if(!IUtility->Strnicmp(parse,"index ",strlen("index ")))    // @index <index>
  1832.     {
  1833.       if(currentry)
  1834.       {
  1835.         CopyLink(parse+strlen("prev "), currentry->Index);
  1836.       }
  1837.       else
  1838.       {
  1839.           CopyLink(parse+strlen("index "), Index);
  1840.       }
  1841.     }
  1842.  
  1843.     if(!IUtility->Strnicmp(parse,"prev ",strlen("prev ")))      // @prev <name>
  1844.     {
  1845.       if(currentry)
  1846.       {
  1847.         CopyLink(parse+strlen("prev "), currentry->Prev);
  1848.       }
  1849.     }
  1850.  
  1851.     if(!IUtility->Strnicmp(parse,"next ",strlen("next ")))      // @next <name>
  1852.     {
  1853.       if(currentry)
  1854.       {
  1855.         CopyLink(parse+strlen("next "), currentry->Next);
  1856.       }
  1857.     }
  1858.  
  1859.     if(!IUtility->Strnicmp(parse,"toc ",strlen("toc ")))        // @toc <name>
  1860.     {
  1861.       if(currentry)
  1862.       {
  1863.         CopyLink(parse+strlen("toc "), currentry->TOC);
  1864.       }
  1865.     }
  1866.  
  1867.     if(!IUtility->Strnicmp(parse,"title ",strlen("title ")))        // @title <name>
  1868.     {
  1869.       if(currentry)
  1870.       {
  1871.       parse = parse+strlen("title ");
  1872.       while(*parse == ' ') parse++;   // Skip spaces
  1873.       if(*parse == '\"') parse++;     // Skip quotation mark
  1874.       title=parse;
  1875.       while(*parse != '\n') parse++;  // search EOL
  1876.       do parse--; while(*parse==' '); // skip trailing spaces
  1877.       if(*parse == '\"') parse--;     // skip trailing quotation mark
  1878.       *++parse = '\0';               // terminate the line
  1879.       strcpy(¤try->Titl,title);
  1880.  
  1881.         //CopyLink(parse+strlen("title "), currentry->Titl);
  1882.         }
  1883.     }
  1884.  
  1885.     if(!IUtility->Strnicmp(parse,"help ",strlen("help ")))        // @help <name>
  1886.     {
  1887.       if(currentry)
  1888.       {
  1889.         CopyLink(parse+strlen("help "), currentry->Help);
  1890.       }
  1891.       else
  1892.       {
  1893.           CopyLink(parse+strlen("help "), Help);
  1894.       }
  1895.     }
  1896.  
  1897.     if(!IUtility->Strnicmp(parse,"endnode",strlen("endnode")))  // @endnode
  1898.     {
  1899.       if(currentry)
  1900.       {
  1901.         IExec->AddTail((struct List *)&entries,(struct Node *)currentry);
  1902.         currentry = NULL;
  1903.       }
  1904.     }
  1905.   }
  1906.   if(currentry)
  1907.   {
  1908.     IExec->AddTail((struct List *)&entries,(struct Node *)currentry);
  1909.     if(!param.nowarn) printf("Line %ld: WARNING: No closing @endnode found!\n",linenr);
  1910. //*    currentry = NULL;
  1911.   }
  1912.  
  1913.   IExec->FreeVec(buffer);
  1914.   return(1);
  1915.  
  1916. ErrorMem:
  1917. sprintf(temp,"Line %ld: Not enough memory!\n",linenr);
  1918.   err(temp,"OK",0);
  1919.   goto Error;
  1920. ErrorBrk:
  1921. sprintf(temp,"Line %ld: <CTRL-C> pressed!\n",linenr);
  1922.   err(temp,"OK",0);
  1923.   goto Error;
  1924. ErrorEOF:
  1925. sprintf(temp,"Line %ld: Unexpected EOF!\n",linenr);
  1926.   err(temp,"OK",0);
  1927. Error:
  1928.   IExec->FreeVec(buffer);
  1929.   return(0);
  1930. }
  1931. //<
  1932.  
  1933. //> main()
  1934. /*------------------------------------------------------------*
  1935. *   main()          M A I N   P R O G R A M                   *
  1936. */
  1937. int main(int argc, char **argv)
  1938. {
  1939.  
  1940.   struct RDArgs *args;
  1941.   static char template[] = "FILE/A,TO/K,URL=HOMEURL/K,FINDURL=SEARCHURL/K,PREV/K,NEXT/K,INDEX/K,TOC/K,HELP/K,RETRACE/K,HOME/K,FIND=SEARCH/K,BAR/K,BODY/K,VER=VERBATIM/S,IMG=IMAGES/S,FTR=FOOTER/S,LA=LINKADD/K,NL=NOLINKS/S,NE=NOEMAIL/S,NW=NOWARN/S,MSDOS/S,SF=SINGLEFILE/S,NONAVBAR/S,NOMOZNAV/S,SHOWALL/S,HTMLHEAD/K,HTMLHEADF/K,HTMLFOOT/K,HTMLFOOTF/K,NOHTML/S,CSS/K,WORDWRAP/S,SMARTWRAP/S,VARWIDTH/S,NOAUTO/S";
  1942.   BPTR fh;
  1943.   BPTR hhf;
  1944.   BPTR oldlock = (BPTR)NULL;
  1945.   struct Entry *node, *next;
  1946.   struct LinkStr *lstr = NULL;
  1947.   struct FileInfoBlock *fib = NULL;
  1948.   long hfs = 4096;
  1949.   long hhs = 4096;
  1950. STRPTR oldlinkadd;
  1951.  
  1952.    if(0 == argc) return(wbmain((struct WBStartup *)argv));
  1953.  
  1954.  
  1955.  
  1956.   IExec->NewList((struct List *)&entries);
  1957.  
  1958.  
  1959. if(!wb)
  1960. {
  1961.   param.prev  = "< Browse";
  1962.   param.next  = "Browse >";
  1963.   param.index = "Index";
  1964.   param.toc   = "Contents";
  1965.   param.home  = "Home";
  1966.   param.help  = "Help";
  1967.   param.find  = "Search";
  1968.   param.bar   = defbar;
  1969.   param.retrace = NULL;
  1970.  
  1971.   if(args = (struct RDArgs *)IDOS->ReadArgs(template,(LONG *)¶m,NULL))
  1972.     {
  1973.         ok=1;
  1974.     }
  1975. }
  1976.  
  1977. if(ok)
  1978.   {
  1979.    if(!wb) IDOS->PutStr("GuideML "VERSIONSTR"\n");
  1980.  
  1981.   textlabs.prev = param.prev;
  1982.   textlabs.next = param.next;
  1983.   textlabs.index = param.index;
  1984.   textlabs.toc = param.toc;
  1985.   textlabs.home = param.home;
  1986.   textlabs.help = param.help;
  1987.   textlabs.find = param.find;
  1988.   textlabs.retrace = param.retrace;
  1989.   textlabs.bar = param.bar;
  1990.  
  1991.     if(param.images)
  1992.     {
  1993.       lstr = IExec->AllocVec(sizeof(struct LinkStr),MEMF_ANY);
  1994.       if(!lstr)
  1995.       {
  1996.         err("**ERROR: Out of memory.","OK",0);
  1997.         goto Flush;
  1998.       }
  1999.  
  2000.       sprintf(lstr->Prev ,"<img src=\"prev.gif\" alt=\"%s\" border=0>" ,param.prev );
  2001.       sprintf(lstr->Next ,"<img src=\"next.gif\" alt=\"%s\" border=0>" ,param.next );
  2002.       sprintf(lstr->Index,"<img src=\"index.gif\" alt=\"%s\" border=0>",param.index);
  2003.       sprintf(lstr->Retrace,"<img src=\"retrace.gif\" alt=\"%s\" border=0>",param.retrace);
  2004.       sprintf(lstr->Toc  ,"<img src=\"toc.gif\" alt=\"%s\" border=0>"  ,param.toc  );
  2005.       sprintf(lstr->Home ,"<img src=\"home.gif\" alt=\"%s\" border=0>" ,param.home );
  2006.       sprintf(lstr->Help ,"<img src=\"help.gif\" alt=\"%s\" border=0>" ,param.help );
  2007.       sprintf(lstr->Find ,"<img src=\"find.gif\" alt=\"%s\" border=0>" ,param.find );
  2008.       param.prev  = lstr->Prev;
  2009.       param.next  = lstr->Next;
  2010.       param.index = lstr->Index;
  2011.       param.toc   = lstr->Toc;
  2012.       param.home  = lstr->Home;
  2013.       param.help  = lstr->Help;
  2014.       param.find  = lstr->Find;
  2015.       if(param.retrace) param.retrace  = lstr->Retrace;
  2016.       if(param.bar == defbar) param.bar = "";
  2017.     }
  2018.  
  2019.     if(param.singlefile)
  2020.     {
  2021.         oldlinkadd = param.linkadd;
  2022.         param.linkadd = "#";
  2023.     }
  2024.  
  2025.     if(param.htmlheadf)
  2026.     {
  2027.         if(hhf=IDOS->Open(param.htmlheadf,MODE_OLDFILE))
  2028.         {
  2029. //        if(IDOS->ExamineFH(hhf,fib))
  2030. //            {
  2031. //                hhs=fib->fib_Size;
  2032.                 if(htmltop = IExec->AllocMem(hhs,MEMF_CLEAR))
  2033.                     {
  2034.                         IDOS->Read(hhf,htmltop,hhs);
  2035.  
  2036.                         param.htmltoptxt=NULL;
  2037.                         if(!wb) printf("%s loaded ok\n",param.htmlheadf);
  2038.  
  2039.                     }
  2040.             IDOS->Close(hhf);
  2041.         }
  2042.     }
  2043.  
  2044.     if(param.htmlfootf)
  2045.     {
  2046.         if(hhf=IDOS->Open(param.htmlfootf,MODE_OLDFILE))
  2047.         {
  2048.                 if(htmlbot = IExec->AllocMem(hfs,MEMF_CLEAR))
  2049.                     {
  2050.                         IDOS->Read(hhf,htmlbot,hfs);
  2051.                         param.htmlbottxt=NULL;
  2052.                         if(!wb) printf("%s loaded ok\n",param.htmlfootf);
  2053.                     }
  2054.             IDOS->Close(hhf);
  2055.         }
  2056.     }
  2057.  
  2058.     if(fh = IDOS->Open(param.from,MODE_OLDFILE))
  2059.     {
  2060.       if(param.to)
  2061.       {
  2062.         BPTR destlock;
  2063.         destlock = IDOS->Lock(param.to,ACCESS_READ);
  2064.         if(!destlock)
  2065.         {
  2066.           err("**ERROR: Couldn't lock destination drawer.","OK",0);
  2067.           IDOS->Close(fh);
  2068.           goto Flush;
  2069.         }
  2070.         oldlock = IDOS->CurrentDir(destlock);
  2071.       }
  2072.  
  2073.       if(!PreScan(fh))
  2074.       {
  2075.         err("**ERROR: Scanning failed.","OK",0);
  2076.         IDOS->Close(fh);
  2077.         goto Flush;
  2078.       }
  2079.       IDOS->Seek(fh,0,OFFSET_BEGINNING);
  2080.       if(!Convert(fh))
  2081.       {
  2082.         err("**ERROR: Conversion failed.","OK",0);
  2083.         IDOS->Close(fh);
  2084.         goto Flush;
  2085.       }
  2086.       IDOS->Close(fh);
  2087.     }
  2088.     else
  2089.     {
  2090. sprintf(temp,"**ERROR: couldn't open file %s!\n",param.from);
  2091.       err(temp,"OK",0);
  2092.     }
  2093.  
  2094.     if(param.images)
  2095.     {
  2096.       if(!wb) IDOS->PutStr("Saving images\n");
  2097.       if(!SaveImages())
  2098.         err("**ERROR: couldn't save image files","OK",0);
  2099.     }
  2100.  
  2101.     if(!wb) printf("All finished!\n");
  2102.  
  2103.     if(param.singlefile)
  2104.     {
  2105.         param.linkadd = oldlinkadd;
  2106.     }
  2107.  
  2108.  
  2109. Flush:
  2110.     for (node = (struct Entry *)entries.mlh_Head;
  2111.          next = (struct Entry *)node->link.mln_Succ;
  2112.          node = next)
  2113.     {
  2114.       IExec->Remove((struct Node *)node);
  2115.       IExec->FreeVec(node);
  2116.     }
  2117.  
  2118.     if(lstr) IExec->FreeVec(lstr);
  2119.     if(htmltop) IExec->FreeMem(htmltop,hhs);
  2120.     if(htmlbot) IExec->FreeMem(htmlbot,hfs);
  2121.  
  2122.  
  2123.     if(oldlock) IDOS->UnLock(IDOS->CurrentDir(oldlock));
  2124.  
  2125.     if(!wb) IDOS->FreeArgs(args);
  2126.   }
  2127.   else
  2128.     IDOS->PutStr("GuideML "VERSIONSTR"\n"
  2129.            "© 1997-98 by Richard Körber <shred@eratosthenes.starfleet.de>\n"
  2130.            "Updated in 2001-04 by Chris Young <chris@unsatisfactorysoftware.co.uk>\n"
  2131.            "Yet Another (tm) AmigaGuide to HTML Converter!\n\n"
  2132.            "USAGE:\tFILE/A\t\t\tAmigaGuide file to be converted\n"
  2133.            "\tTO/K\t\t\tDestination drawer for the html pages\n"
  2134.            "\tURL=HOMEURL/K\t\tURL accessed by the 'HOME' button\n"
  2135.            "\tFINDURL=SEARCHURL/K\tURL accessed by the 'SEARCH' button\n"
  2136.            "\tPREV/K\t\t\t'PREV' button text/image\n"
  2137.            "\tNEXT/K\t\t\t'NEXT' button text/image\n"
  2138.            "\tINDEX/K\t\t\t'INDEX' button text/image\n"
  2139.            "\tTOC/K\t\t\t'CONTENTS' button text/image\n"
  2140.            "\tHELP/K\t\t\t'HELP' button text/image\n"
  2141.            "\tRETRACE/K\t\t'RETRACE' button text/image (displays only if specified)\n"
  2142.            "\tHOME/K\t\t\t'HOME' button text/image\n"
  2143.            "\tFIND=SEARCH/K\t\t'SEARCH' button text/image\n"
  2144.            "\tBAR/K\t\t\tBar text between navigation buttons\n"
  2145.            "\tBODY/K\t\t\tAddition to the body tag of every page\n"
  2146.            "\tVER=VERBATIM/S\t\tList of created files\n"
  2147.            "\tIMG=IMAGES/S\t\tCreate image navigation bar\n"
  2148.            "\tFTR=FOOTER/S\t\tNavigation bar also at end of page\n"
  2149.            "\tLA=LINKADD/K\t\tText to add to the start of each page URLs\n"
  2150.            "\tNL=NOLINKS/S\t\tIgnore internet links\n"
  2151.            "\tNE=NOEMAIL/S\t\tIgnore e-mail addresses\n"
  2152.            "\tNW=NOWARN/S\t\tDon't show warnings\n"
  2153.            "\tMSDOS/S\t\t\tCreate MS-DOS filenames (*.htm)\n"
  2154.            "\tSF=SINGLEFILE/S\t\tPut all nodes into a single HTML file\n"
  2155.            "\tNONAVBAR/S\t\tDo not create the HTML navigation bar\n"
  2156.            "\tNOMOZNAV/S\t\tDo not create Mozilla-compatible Site Navigation Bar\n"
  2157.            "\tSHOWALL/S\t\tKeep navbar consistent between pages\n"
  2158.            "\tHTMLHEAD/K\t\tHTML to put in front of guide text\n"
  2159.            "\tHTMLHEADF/K\t\tFile containing HTMLHEAD (overrides HTMLHEAD)\n"
  2160.            "\tHTMLFOOT/K\t\tHTML to put underneath guide text\n"
  2161.            "\tHTMLFOOTF/K\t\tFile containing HTMLFOOT (overrides HTMLFOOT)\n"
  2162.            "\tNOHTML/K\t\tDo not auto-generate HTML headers or footers\n"
  2163.            "\tCSS/K\t\t\tURL of Cascading Style Sheet to link to\n"
  2164.            "\tWORDWRAP/S\t\tWord-wraps text (converts @wordwrap)\n"
  2165.            "\tSMARTWRAP/S\t\tSmartwraps text (converts @smartwrap)\n"
  2166.            "\tVARWIDTH/S\t\tDo not use fixed width font (#?WRAP only)\n"
  2167.            "\tNOAUTO/S\t\tDo not auto-detect wrap mode\n"
  2168.  
  2169.            "\n");
  2170.   return(0);
  2171. }
  2172. //<
  2173.  
  2174. /**************************************************************/
  2175.  
  2176. /* New GuiML stuff starts here.. code might be a bit messy *
  2177.  * as it is largely cut'n'paste from a different project   *
  2178.  * --- Starts with GuideML 3.1 ---                         */
  2179.  
  2180. int wbmain(struct WBStartup *WBenchMsg)
  2181. {
  2182. struct WBArg *wbarg;
  2183.     char i;
  2184.     int olddir;
  2185. int name = 0;
  2186.  
  2187. wb=1;
  2188. ok=1;
  2189.  
  2190.   param.prev  = "< Browse";
  2191.   param.next  = "Browse >";
  2192.   param.index = "Index";
  2193.   param.toc   = "Contents";
  2194.   param.home  = "Home";
  2195.   param.help  = "Help";
  2196.   param.find  = "Search";
  2197.   param.bar   = defbar;
  2198.   param.retrace = NULL;
  2199.  
  2200. param.nowarn = TRUE;
  2201.  
  2202.     if((GadToolsBase = IExec->OpenLibrary("gadtools.library",50))==0)
  2203.         {
  2204.          err("Unable to open gadtools.library v50","OK",20);
  2205.         }
  2206.     IGadTools=(struct GadToolsIFace *)IExec->GetInterface(GadToolsBase,"main",1,NULL);
  2207.  
  2208.     if((UtilityBase = IExec->OpenLibrary("utility.library",50))==0)
  2209.         {
  2210.          err("Unable to open utility.library v50","OK",20);
  2211.         }
  2212.     IUtility=(struct UtilityIFace *)IExec->GetInterface(UtilityBase,"main",1,NULL);
  2213.  
  2214. /*
  2215.     if((DOSBase = OpenLibrary("dos.library",37))==0)
  2216.         {
  2217.           err("Unable to open dos.library v37","OK",20);
  2218.         }
  2219.  
  2220.     if((aslbase = OpenLibrary("asl.library",38))==0)
  2221.         {
  2222.           err("Unable to open asl.library v38","OK",20);
  2223.         }
  2224.     if((GadToolsBase = OpenLibrary("gadtools.library",37))==0)
  2225.         {
  2226.           err("Unable to open gadtools.library v37","OK",20);
  2227.         }
  2228.  
  2229.      if((WindowBase = OpenLibrary("window.class",44))==0) err("Unable to open window.class v44","OK",20);
  2230.      if((LayoutBase = OpenLibrary("gadgets/layout.gadget",44))==0) err("Unable to open layout.gadget v44","OK",20);
  2231.      if((ButtonBase = OpenLibrary("gadgets/button.gadget",44))==0) err("Unable to open button.gadget v44","OK",20);
  2232.      if((CheckBoxBase = OpenLibrary("gadgets/checkbox.gadget",44))==0) err("Unable to open checkbox.gadget v44","OK",20);
  2233.      if((LabelBase = OpenLibrary("images/label.image",44))==0) err("Unable to open label.image v44","OK",20);
  2234.      if((ChooserBase = OpenLibrary("gadgets/chooser.gadget",44))==0) err("Unable to open chooser.gadget v44","OK",20);
  2235.      if((ClickTabBase = OpenLibrary("gadgets/clicktab.gadget",44))==0) err("Unable to open clicktab.gadget v44","OK",20);
  2236. //     if((IntegerBase = OpenLibrary("gadgets/integer.gadget",44))==0) err("Unable to open integer.gadget v44","OK",20);
  2237. //     if((ListBrowserBase = OpenLibrary("gadgets/listbrowser.gadget",44))==0) err("Unable to open listbrowser.gadget v44","OK",20);
  2238.      if((GetFileBase = OpenLibrary("gadgets/getfile.gadget",44))==0) err("Unable to open getfile.gadget v44","OK",20);
  2239.      if((StringBase = OpenLibrary("gadgets/string.gadget",44))==0) err("Unable to open string.gadget v44","OK",20);
  2240.  
  2241.  
  2242.     IconBase = OpenLibrary("icon.library",44);
  2243.     if(!IconBase) err("Cannot open icon.library v44","OK",20);
  2244. */
  2245.  
  2246.     for(i=0,wbarg=WBenchMsg->sm_ArgList;i<WBenchMsg->sm_NumArgs;i++,wbarg++)
  2247.         {
  2248.         olddir =-1;
  2249.         if((wbarg->wa_Lock)&&(*wbarg->wa_Name))
  2250.             olddir = IDOS->CurrentDir(wbarg->wa_Lock);
  2251. if(!name)
  2252. {
  2253. strcpy(defname,"PROGDIR:");
  2254.  IDOS->AddPart(defname,wbarg->wa_Name,100);
  2255.  name=1;
  2256. }
  2257.  
  2258.         gettooltypes(wbarg);
  2259.  
  2260.         if(olddir !=-1) IDOS->CurrentDir(olddir);
  2261.         }
  2262.  
  2263. ui();
  2264.  
  2265. }
  2266.  
  2267. void gettooltypes(struct WBArg *wbarg)
  2268. {
  2269.     struct DiskObject *dobj;
  2270.     CONST_STRPTR *toolarray;
  2271.     char *s;
  2272.  
  2273.  
  2274.     if((*wbarg->wa_Name) && (dobj=IIcon->GetIconTags(wbarg->wa_Name,NULL)))
  2275.         {
  2276.         toolarray = (CONST_STRPTR *)dobj->do_ToolTypes;
  2277.         if(s = (char *)IIcon->FindToolType(toolarray,"FILE"))
  2278.             {
  2279.                 ttfrom = IExec->AllocMem(strlen(s)+1,NULL);
  2280.                 if(ttfrom)
  2281.                     {
  2282.                          strcpy(ttfrom,s);
  2283.                          param.from = ttfrom;
  2284.                     }
  2285.             }
  2286.         if(s = (char *)IIcon->FindToolType(toolarray,"TO"))
  2287.             {
  2288.                 ttto = IExec->AllocMem(strlen(s)+1,NULL);
  2289.                 if(ttto)
  2290.                     {
  2291.                          strcpy(ttto,s);
  2292.                          param.to = ttto;
  2293.                     }
  2294.             }
  2295.  
  2296.         if(s = (char *)IIcon->FindToolType(toolarray,"HOMEURL"))
  2297.             {
  2298.                 tthomeurl = IExec->AllocMem(strlen(s)+1,NULL);
  2299.                 if(tthomeurl)
  2300.                     {
  2301.                          strcpy(tthomeurl,s);
  2302.                          param.homeurl = tthomeurl;
  2303.                     }
  2304.             }
  2305.  
  2306.         if(s = (char *)IIcon->FindToolType(toolarray,"SEARCHURL"))
  2307.             {
  2308.                 ttfindurl = IExec->AllocMem(strlen(s)+1,NULL);
  2309.                 if(ttfindurl)
  2310.                     {
  2311.                          strcpy(ttfindurl,s);
  2312.                          param.findurl = ttfindurl;
  2313.                     }
  2314.             }
  2315.  
  2316.         if(s = (char *)IIcon->FindToolType(toolarray,"PREV"))
  2317.             {
  2318.                 ttprev = IExec->AllocMem(strlen(s)+1,NULL);
  2319.                 if(ttprev)
  2320.                     {
  2321.                          strcpy(ttprev,s);
  2322.                          param.prev = ttprev;
  2323.                     }
  2324.             }
  2325.  
  2326.         if(s = (char *)IIcon->FindToolType(toolarray,"NEXT"))
  2327.             {
  2328.                 ttnext = IExec->AllocMem(strlen(s)+1,NULL);
  2329.                 if(ttnext)
  2330.                     {
  2331.                          strcpy(ttnext,s);
  2332.                          param.next = ttnext;
  2333.                     }
  2334.             }
  2335.  
  2336.         if(s = (char *)IIcon->FindToolType(toolarray,"INDEX"))
  2337.             {
  2338.                 ttindex = IExec->AllocMem(strlen(s)+1,NULL);
  2339.                 if(ttindex)
  2340.                     {
  2341.                          strcpy(ttindex,s);
  2342.                          param.index = ttindex;
  2343.                     }
  2344.             }
  2345.  
  2346.         if(s = (char *)IIcon->FindToolType(toolarray,"TOC"))
  2347.             {
  2348.                 tttoc = IExec->AllocMem(strlen(s)+1,NULL);
  2349.                 if(tttoc)
  2350.                     {
  2351.                          strcpy(tttoc,s);
  2352.                          param.toc = tttoc;
  2353.                     }
  2354.             }
  2355.  
  2356.         if(s = (char *)IIcon->FindToolType(toolarray,"HELP"))
  2357.             {
  2358.                 tthelp = IExec->AllocMem(strlen(s)+1,NULL);
  2359.                 if(tthelp)
  2360.                     {
  2361.                          strcpy(tthelp,s);
  2362.                          param.help = tthelp;
  2363.                     }
  2364.             }
  2365.  
  2366.         if(s = (char *)IIcon->FindToolType(toolarray,"RETRACE"))
  2367.             {
  2368.                 ttretrace = IExec->AllocMem(strlen(s)+1,NULL);
  2369.                 if(ttretrace)
  2370.                     {
  2371.                          strcpy(ttretrace,s);
  2372.                          param.retrace = ttretrace;
  2373.                     }
  2374.             }
  2375.  
  2376.         if(s = (char *)IIcon->FindToolType(toolarray,"HOME"))
  2377.             {
  2378.                 tthome = IExec->AllocMem(strlen(s)+1,NULL);
  2379.                 if(tthome)
  2380.                     {
  2381.                          strcpy(tthome,s);
  2382.                          param.home = tthome;
  2383.                     }
  2384.             }
  2385.  
  2386.         if(s = (char *)IIcon->FindToolType(toolarray,"SEARCH"))
  2387.             {
  2388.                 ttfind = IExec->AllocMem(strlen(s)+1,NULL);
  2389.                 if(ttfind)
  2390.                     {
  2391.                          strcpy(ttfind,s);
  2392.                          param.find = ttfind;
  2393.                     }
  2394.             }
  2395.  
  2396.         if(s = (char *)IIcon->FindToolType(toolarray,"BAR"))
  2397.             {
  2398.                 ttbar = IExec->AllocMem(strlen(s)+1,NULL);
  2399.                 if(ttbar)
  2400.                     {
  2401.                          strcpy(ttbar,s);
  2402.                          param.bar = ttbar;
  2403.                     }
  2404.             }
  2405.  
  2406.         if(s = (char *)IIcon->FindToolType(toolarray,"BODY"))
  2407.             {
  2408.                 ttbody = IExec->AllocMem(strlen(s)+1,NULL);
  2409.                 if(ttbody)
  2410.                     {
  2411.                          strcpy(ttbody,s);
  2412.                          param.bodyext = ttbody;
  2413.                     }
  2414.             }
  2415.  
  2416.         if(s = (char *)IIcon->FindToolType(toolarray,"HTMLHEADF"))
  2417.             {
  2418.                 tthtmlheadf = IExec->AllocMem(strlen(s)+1,NULL);
  2419.                 if(tthtmlheadf)
  2420.                     {
  2421.                          strcpy(tthtmlheadf,s);
  2422.                          param.htmlheadf = tthtmlheadf;
  2423.                     }
  2424.             }
  2425.  
  2426.         if(s = (char *)IIcon->FindToolType(toolarray,"HTMLFOOTF"))
  2427.             {
  2428.                 tthtmlfootf = IExec->AllocMem(strlen(s)+1,NULL);
  2429.                 if(tthtmlfootf)
  2430.                     {
  2431.                          strcpy(tthtmlfootf,s);
  2432.                          param.htmlfootf = tthtmlfootf;
  2433.                     }
  2434.             }
  2435.  
  2436.         if(s = (char *)IIcon->FindToolType(toolarray,"LINKADD"))
  2437.             {
  2438.                 ttlinkadd = IExec->AllocMem(strlen(s)+1,NULL);
  2439.                 if(ttlinkadd)
  2440.                     {
  2441.                          strcpy(ttlinkadd,s);
  2442.                          param.linkadd = ttlinkadd;
  2443.                     }
  2444.             }
  2445.  
  2446.         if(s = (char *)IIcon->FindToolType(toolarray,"CSS"))
  2447.             {
  2448.                 ttcss = IExec->AllocMem(strlen(s)+1,NULL);
  2449.                 if(ttcss)
  2450.                     {
  2451.                          strcpy(ttcss,s);
  2452.                          param.cssurl = ttcss;
  2453.                     }
  2454.             }
  2455.  
  2456.         if(s = (char *)IIcon->FindToolType(toolarray,"SINGLEFILE")) param.singlefile = TRUE;
  2457.         if(s = (char *)IIcon->FindToolType(toolarray,"NOHTML")) param.nohtml = TRUE;
  2458.         if(s = (char *)IIcon->FindToolType(toolarray,"IMAGES")) param.images = TRUE;
  2459.         if(s = (char *)IIcon->FindToolType(toolarray,"FOOTER")) param.footer = TRUE;
  2460.         if(s = (char *)IIcon->FindToolType(toolarray,"NOLINKS")) param.nolink = TRUE;
  2461.         if(s = (char *)IIcon->FindToolType(toolarray,"NOEMAIL")) param.noemail = TRUE;
  2462.         if(s = (char *)IIcon->FindToolType(toolarray,"MSDOS")) param.msdos = TRUE;
  2463.         if(s = (char *)IIcon->FindToolType(toolarray,"NONAVBAR")) param.nonavbar = TRUE;
  2464.         if(s = (char *)IIcon->FindToolType(toolarray,"NOMOZNAV")) param.nomoznav = TRUE;
  2465.         if(s = (char *)IIcon->FindToolType(toolarray,"SHOWALL")) param.showall = TRUE;
  2466.         if(s = (char *)IIcon->FindToolType(toolarray,"VARWIDTH")) param.varwidth = TRUE;
  2467.         if(s = (char *)IIcon->FindToolType(toolarray,"NOAUTO")) param.noauto = TRUE;
  2468.         if(s = (char *)IIcon->FindToolType(toolarray,"WORDWRAP")) param.wordwrap = TRUE;
  2469.         if(s = (char *)IIcon->FindToolType(toolarray,"SMARTWRAP")) param.smartwrap = TRUE;
  2470.         IIcon->FreeDiskObject(dobj);
  2471.         }
  2472.  
  2473. }
  2474.  
  2475. void savetooltypes(char *fname,int def)
  2476. {
  2477.     struct DiskObject *dobj;
  2478.     UBYTE **oldtooltypes;
  2479.     UBYTE *olddefaulttool;
  2480.     UBYTE oldtype;
  2481.     long olddir=-1;
  2482.     UBYTE *newtooltypes[35];
  2483.     char tttmp1[100];
  2484.     char tttmp2[100];
  2485.     char tttmp3[100];
  2486.     char tttmp4[100];
  2487.     char tttmp5[100];
  2488.     char tttmp6[100];
  2489.     char tttmp7[100];
  2490.     char tttmp8[100];
  2491.     char tttmp9[100];
  2492.     char tttmp10[100];
  2493.     char tttmp11[100];
  2494.     char tttmp12[100];
  2495.     char tttmp13[100];
  2496.     char tttmp14[100];
  2497.     char tttmp15[100];
  2498.     char tttmp16[100];
  2499.     char tttmp17[100];
  2500.     char tttmp18[100];
  2501.     char defaulttool[] = "guideml\0";
  2502.  
  2503. //char *fname="progdir:guideml\0";
  2504.  
  2505. // if((wbarg->wa_Lock) && (wbarg->wa_Name)) olddir=CurrentDir(wbarg->wa_Lock);
  2506.  
  2507. //    if((*wbarg->wa_Name) && (dobj=GetDiskObject(wbarg->wa_Name)))
  2508.     if(dobj=IIcon->GetIconTags(fname,ICONGETA_FailIfUnavailable,FALSE,NULL))
  2509.         {
  2510.             oldtooltypes = dobj->do_ToolTypes;
  2511.             olddefaulttool = dobj->do_DefaultTool;
  2512.             oldtype = dobj->do_Type;
  2513.  
  2514.             if(param.smartwrap) newtooltypes[0] = "SMARTWRAP";
  2515.                                 else newtooltypes[0] = "(SMARTWRAP)";
  2516.             if(param.wordwrap) newtooltypes[1] = "WORDWRAP";
  2517.                                 else newtooltypes[1] = "(WORDWRAP)";
  2518.             if(param.noauto) newtooltypes[2] = "NOAUTO";
  2519.                                 else newtooltypes[2] = "(NOAUTO)";
  2520.             if(param.varwidth) newtooltypes[3] = "VARWIDTH";
  2521.                                 else newtooltypes[3] = "(VARWIDTH)";
  2522.             if(param.showall) newtooltypes[4] = "SHOWALL";
  2523.                                 else newtooltypes[4] = "(SHOWALL)";
  2524.             if(param.nomoznav) newtooltypes[5] = "NOMOZNAV";
  2525.                                 else newtooltypes[5] = "(NOMOZNAV)";
  2526.             if(param.nonavbar) newtooltypes[6] = "NONAVBAR";
  2527.                                 else newtooltypes[6] = "(NONAVBAR)";
  2528.             if(param.msdos) newtooltypes[7] = "MSDOS";
  2529.                                 else newtooltypes[7] = "(MSDOS)";
  2530.             if(param.noemail) newtooltypes[8] = "NOEMAIL";
  2531.                                 else newtooltypes[8] = "(NOEMAIL)";
  2532.             if(param.nolink) newtooltypes[9] = "NOLINKS";
  2533.                                 else newtooltypes[9] = "(NOLINKS)";
  2534.             if(param.footer) newtooltypes[10] = "FOOTER";
  2535.                                 else newtooltypes[10] = "(FOOTER)";
  2536.             if(param.images) newtooltypes[11] = "IMAGES";
  2537.                                 else newtooltypes[11] = "(IMAGES)";
  2538.             if(param.cssurl)
  2539.             {
  2540.                 strcpy(tttmp1,"CSS=");
  2541.                 newtooltypes[12] = strcat(tttmp1,param.cssurl);
  2542.             }
  2543.                 else
  2544.             {
  2545.                 newtooltypes[12]="(CSS=)";
  2546.             }
  2547.  
  2548.             if(param.htmlfootf)
  2549.             {
  2550.                 strcpy(tttmp2,"HTMLFOOTF=");
  2551.                 newtooltypes[13] = strcat(tttmp2,param.htmlfootf);
  2552.             }
  2553.                 else
  2554.             {
  2555.                 newtooltypes[13]="(HTMLFOOTF=)";
  2556.             }
  2557.  
  2558.             if(param.htmlheadf)
  2559.             {
  2560.                 strcpy(tttmp3,"HTMLHEADF=");
  2561.                 newtooltypes[14] = strcat(tttmp3,param.htmlheadf);
  2562.             }
  2563.                 else
  2564.             {
  2565.                 newtooltypes[14]="(HTMLHEADF=)";
  2566.             }
  2567.  
  2568.             if(param.bodyext)
  2569.             {
  2570.                 strcpy(tttmp4,"BODY=");
  2571.                 newtooltypes[15] = strcat(tttmp4,param.bodyext);
  2572.             }
  2573.                 else
  2574.             {
  2575.                 newtooltypes[15]="(BODY=)";
  2576.             }
  2577.  
  2578.             if(param.bar)
  2579.             {
  2580.                 strcpy(tttmp5,"BAR=");
  2581.                 newtooltypes[16] = strcat(tttmp5,param.bar);
  2582.             }
  2583.                 else
  2584.             {
  2585.                 newtooltypes[16]="(BAR=)";
  2586.             }
  2587.  
  2588.             if(param.find)
  2589.             {
  2590.                 strcpy(tttmp6,"SEARCH=");
  2591.                 newtooltypes[17] = strcat(tttmp6,param.find);
  2592.             }
  2593.                 else
  2594.             {
  2595.                 newtooltypes[17]="(SEARCH=)";
  2596.             }
  2597.  
  2598.             if(param.home)
  2599.             {
  2600.                 strcpy(tttmp7,"HOME=");
  2601.                 newtooltypes[18] = strcat(tttmp7,param.home);
  2602.             }
  2603.                 else
  2604.             {
  2605.                 newtooltypes[18]="(HOME=)";
  2606.             }
  2607.  
  2608.             if(param.retrace)
  2609.             {
  2610.                 strcpy(tttmp8,"RETRACE=");
  2611.                 newtooltypes[19] = strcat(tttmp8,param.retrace);
  2612.             }
  2613.                 else
  2614.             {
  2615.                 newtooltypes[19]="(RETRACE=)";
  2616.             }
  2617.  
  2618.             if(param.help)
  2619.             {
  2620.                 strcpy(tttmp9,"HELP=");
  2621.                 newtooltypes[20] = strcat(tttmp9,param.help);
  2622.             }
  2623.                 else
  2624.             {
  2625.                 newtooltypes[20]="(HELP=)";
  2626.             }
  2627.  
  2628.             if(param.toc)
  2629.             {
  2630.                 strcpy(tttmp10,"TOC=");
  2631.                 newtooltypes[21] = strcat(tttmp10,param.toc);
  2632.             }
  2633.                 else
  2634.             {
  2635.                 newtooltypes[21]="(TOC=)";
  2636.             }
  2637.  
  2638.             if(param.index)
  2639.             {
  2640.                 strcpy(tttmp11,"INDEX=");
  2641.                 newtooltypes[22] = strcat(tttmp11,param.index);
  2642.             }
  2643.                 else
  2644.             {
  2645.                 newtooltypes[22]="(INDEX=)";
  2646.             }
  2647.  
  2648.             if(param.next)
  2649.             {
  2650.                 strcpy(tttmp12,"NEXT=");
  2651.                 newtooltypes[23] = strcat(tttmp12,param.next);
  2652.             }
  2653.                 else
  2654.             {
  2655.                 newtooltypes[23]="(NEXT=)";
  2656.             }
  2657.  
  2658.             if(param.prev)
  2659.             {
  2660.                 strcpy(tttmp13,"PREV=");
  2661.                 newtooltypes[24] = strcat(tttmp13,param.prev);
  2662.             }
  2663.                 else
  2664.             {
  2665.                 newtooltypes[24]="(PREV=)";
  2666.             }
  2667.  
  2668.             if(param.findurl)
  2669.             {
  2670.                 strcpy(tttmp14,"SEARCHURL=");
  2671.                 newtooltypes[25] = strcat(tttmp14,param.findurl);
  2672.             }
  2673.                 else
  2674.             {
  2675.                 newtooltypes[25]="(SEARCHURL=)";
  2676.             }
  2677.  
  2678.             if(param.homeurl)
  2679.             {
  2680.                 strcpy(tttmp15,"HOMEURL=");
  2681.                 newtooltypes[26] = strcat(tttmp15,param.homeurl);
  2682.             }
  2683.                 else
  2684.             {
  2685.                 newtooltypes[26]="(HOMEURL=)";
  2686.             }
  2687.  
  2688.             if(param.linkadd)
  2689.             {
  2690.                 strcpy(tttmp18,"LINKADD=");
  2691.                 newtooltypes[27] = strcat(tttmp18,param.linkadd);
  2692.             }
  2693.                 else
  2694.             {
  2695.                 newtooltypes[27]="(LINKADD=)";
  2696.             }
  2697.  
  2698.             if(param.nohtml) newtooltypes[28] = "NOHTML";
  2699.                                 else newtooltypes[28] = "(NOHTML)";
  2700.  
  2701.             if(param.singlefile) newtooltypes[29] = "SINGLEFILE";
  2702.                                 else newtooltypes[29] = "(SINGLEFILE)";
  2703.  
  2704.         if(!def)
  2705.         {
  2706.  
  2707.             if(param.to)
  2708.             {
  2709.                 strcpy(tttmp16,"TO=");
  2710.                 newtooltypes[30] = strcat(tttmp16,param.to);
  2711.             }
  2712.                 else
  2713.             {
  2714.                 newtooltypes[30]="(TO=)";
  2715.             }
  2716.  
  2717.             if(param.from)
  2718.             {
  2719.                 strcpy(tttmp17,"FILE=");
  2720.                 newtooltypes[31] = strcat(tttmp17,param.from);
  2721.             }
  2722.                 else
  2723.             {
  2724.                 newtooltypes[31]="(FILE=)";
  2725.             }
  2726.  
  2727.             dobj->do_DefaultTool = defaulttool;
  2728.             dobj->do_Type = WBPROJECT;
  2729.  
  2730.         }
  2731.         else
  2732.         {
  2733.             newtooltypes[30]=NULL;
  2734.         }
  2735.  
  2736.             newtooltypes[32] = NULL;
  2737.             dobj->do_ToolTypes = newtooltypes;
  2738.             IIcon->PutIconTags(fname,dobj,NULL); //            PutDiskObject(fname,dobj); // PutDiskObject(wbarg->wa_Name,dobj);
  2739.             dobj->do_ToolTypes=oldtooltypes;
  2740.             dobj->do_DefaultTool=olddefaulttool;
  2741.             dobj->do_Type = oldtype;
  2742.             IIcon->FreeDiskObject(dobj);
  2743.         }
  2744.  
  2745. // if(olddir!=-1) CurrentDir(olddir);
  2746.  
  2747. }
  2748.  
  2749. int saveas()
  2750. {
  2751.     BPTR fp;
  2752.     int t;
  2753.     char *filename[2048];
  2754.     char guidemlcmd[4096];
  2755.     struct FileRequester *req;
  2756.     struct TagItem asltags[] = {ASLFR_TitleText,(ULONG)"Save As...",
  2757.                              ASLFR_InitialShowVolumes,TRUE,
  2758.                              ASLFR_DoSaveMode,TRUE,TAG_DONE};
  2759.  
  2760.     req = (struct FileRequester *)IAsl->AllocAslRequest(ASL_FileRequest,NULL);
  2761.     t = IAsl->AslRequest(req,asltags);
  2762.  
  2763.     if (t==FALSE)
  2764.    {
  2765.         // user cancelled
  2766.         return(0);
  2767.     }
  2768.  
  2769.     strcpy((STRPTR)filename,req->fr_Drawer);
  2770.     IDOS->AddPart((STRPTR)filename,req->fr_File,2048);
  2771.  
  2772.     IAsl->FreeAslRequest(req);
  2773.  
  2774.     fp = IDOS->Open((STRPTR)filename,MODE_NEWFILE);
  2775.  
  2776.     strcpy(guidemlcmd,"guideml \"");
  2777.     if(param.from) strcat(guidemlcmd,param.from);
  2778.     if(param.from) strcat(guidemlcmd,"\" ");
  2779.     if(param.to) strcat(guidemlcmd,"TO=\"");
  2780.     if(param.to) strcat(guidemlcmd,param.to);
  2781.     if(param.to) strcat(guidemlcmd,"\" ");
  2782.     if(param.homeurl) strcat(guidemlcmd,"HOMEURL=\"");
  2783.     if(param.homeurl) strcat(guidemlcmd,param.homeurl);
  2784.     if(param.homeurl) strcat(guidemlcmd,"\" ");
  2785.     if(param.prev) strcat(guidemlcmd,"PREV=\"");
  2786.     if(param.prev) strcat(guidemlcmd,param.prev);
  2787.     if(param.prev) strcat(guidemlcmd,"\" ");
  2788.     if(param.next) strcat(guidemlcmd,"NEXT=\"");
  2789.     if(param.next) strcat(guidemlcmd,param.next);
  2790.     if(param.next) strcat(guidemlcmd,"\" ");
  2791.     if(param.index) strcat(guidemlcmd,"INDEX=\"");
  2792.     if(param.index) strcat(guidemlcmd,param.index);
  2793.     if(param.index) strcat(guidemlcmd,"\" ");
  2794.     if(param.toc) strcat(guidemlcmd,"TOC=\"");
  2795.     if(param.toc) strcat(guidemlcmd,param.toc);
  2796.     if(param.toc) strcat(guidemlcmd,"\" ");
  2797.     if(param.help) strcat(guidemlcmd,"HELP=\"");
  2798.     if(param.help) strcat(guidemlcmd,param.help);
  2799.     if(param.help) strcat(guidemlcmd,"\" ");
  2800.     if(param.retrace) strcat(guidemlcmd,"RETRACE=\"");
  2801.     if(param.retrace) strcat(guidemlcmd,param.retrace);
  2802.     if(param.retrace) strcat(guidemlcmd,"\" ");
  2803.     if(param.home) strcat(guidemlcmd,"HOME=\"");
  2804.     if(param.home) strcat(guidemlcmd,param.home);
  2805.     if(param.home) strcat(guidemlcmd,"\" ");
  2806.     if(param.bar) strcat(guidemlcmd,"BAR=\"");
  2807.     if(param.bar) strcat(guidemlcmd,param.bar);
  2808.     if(param.bar) strcat(guidemlcmd,"\" ");
  2809.     if(param.bodyext) strcat(guidemlcmd,"BODY=\"");
  2810.     if(param.bodyext) strcat(guidemlcmd,param.bodyext);
  2811.     if(param.bodyext) strcat(guidemlcmd,"\" ");
  2812.     if(param.htmlheadf) strcat(guidemlcmd,"HTMLHEADF=\"");
  2813.     if(param.htmlheadf) strcat(guidemlcmd,param.htmlheadf);
  2814.     if(param.htmlheadf) strcat(guidemlcmd,"\" ");
  2815.     if(param.htmlfootf) strcat(guidemlcmd,"HTMLFOOTF=\"");
  2816.     if(param.htmlfootf) strcat(guidemlcmd,param.htmlfootf);
  2817.     if(param.htmlfootf) strcat(guidemlcmd,"\" ");
  2818.     if(param.cssurl) strcat(guidemlcmd,"CSS=\"");
  2819.     if(param.cssurl) strcat(guidemlcmd,param.cssurl);
  2820.     if(param.cssurl) strcat(guidemlcmd,"\" ");
  2821.     if(param.nohtml) strcat(guidemlcmd,"NOHTML ");
  2822.     if(param.images) strcat(guidemlcmd,"IMAGES ");
  2823.     if(param.footer) strcat(guidemlcmd,"FOOTER ");
  2824.     if(param.linkadd) strcat(guidemlcmd,"LINKADD=\"");
  2825.     if(param.linkadd) strcat(guidemlcmd,param.linkadd);
  2826.     if(param.linkadd) strcat(guidemlcmd,"\" ");
  2827.     if(param.nolink) strcat(guidemlcmd,"NOLINKS ");
  2828.     if(param.noemail) strcat(guidemlcmd,"NOEMAIL ");
  2829.     if(param.msdos) strcat(guidemlcmd,"MSDOS ");
  2830.     if(param.singlefile) strcat(guidemlcmd,"SINGLEFILE ");
  2831.     if(param.nonavbar) strcat(guidemlcmd,"NONAVBAR ");
  2832.     if(param.nomoznav) strcat(guidemlcmd,"NOMOZNAV ");
  2833.     if(param.showall) strcat(guidemlcmd,"SHOWALL ");
  2834.     if(param.wordwrap) strcat(guidemlcmd,"WORDWRAP ");
  2835.     if(param.smartwrap) strcat(guidemlcmd,"SMARTWRAP ");
  2836.     if(param.varwidth) strcat(guidemlcmd,"VARWIDTH ");
  2837.     if(param.noauto) strcat(guidemlcmd,"NOAUTO ");
  2838.     strcat(guidemlcmd,"\n");
  2839.  
  2840.  
  2841.     IDOS->FPuts(fp,guidemlcmd);
  2842.  
  2843.     IDOS->Close(fp);
  2844.  
  2845.     savetooltypes((STRPTR)filename,0);
  2846. }
  2847.  
  2848.  
  2849. void ui()
  2850. {
  2851.     long i=0; // temp variable
  2852.     struct List optlist;
  2853.     struct List navoptlist;
  2854.     struct List imgoptlist;
  2855.     struct List linkoptlist;
  2856.     struct List tablist;
  2857.     struct MsgPort *AppPort;
  2858.  
  2859.     struct Window *windows[WID_LAST];
  2860.     Object *objects[OID_LAST];
  2861.  
  2862.     UBYTE *opts[] = {"Auto","Wordwrap","Smartwrap","None",NULL};
  2863.     UBYTE *navopts[] = {"Header","Both","None",NULL};
  2864.     UBYTE *linkopts[] = {"Convert All","Not Email","Email Only","None",NULL};
  2865.     UBYTE *imgopts[] = {"Text","Images",NULL};
  2866.     UBYTE *tabs[] = {"Convert","Options",NULL};
  2867.         struct Menu *menustrip;
  2868.     UWORD menunum,itemnum,subnum; //menusel;
  2869.     struct MenuItem *item;
  2870.     int wrapm =0;
  2871.     int navm=0;
  2872.     int linkm=0;
  2873.  
  2874. if(param.noauto) wrapm = 3;
  2875. if(param.wordwrap) wrapm = 1;
  2876. if(param.smartwrap) wrapm = 2;
  2877. if(!param.noauto) wrapm = 0;
  2878.  
  2879. if(param.footer) navm = 1;
  2880. if(param.nonavbar) navm=2;
  2881.  
  2882. if(param.noemail) linkm=1;
  2883. if(param.nolink) linkm=linkm+2;
  2884.  
  2885. make_list(&optlist,opts);
  2886. make_list(&navoptlist,navopts);
  2887. make_list(&imgoptlist,imgopts);
  2888. make_list(&linkoptlist,linkopts);
  2889. maketablist(&tablist,tabs);
  2890.  
  2891.     if ( AppPort = IExec->CreateMsgPort() )
  2892.     {
  2893.         /* Create the window object.
  2894.          */
  2895.         objects[OID_MAIN] = WindowObject,
  2896.             WA_ScreenTitle, "GuideML " VERSIONSTR " (" VERSIONDATE ")",
  2897.             WA_Title, "GuideML",
  2898.             WA_Activate, TRUE,
  2899.             WA_DepthGadget, TRUE,
  2900.             WA_DragBar, TRUE,
  2901.             WA_CloseGadget, TRUE,
  2902.             WA_SizeGadget, TRUE,
  2903.             WA_SmartRefresh,TRUE,
  2904.             WA_IDCMP,IDCMP_MENUPICK,
  2905.             WINDOW_IconifyGadget, FALSE,
  2906.             WINDOW_IconTitle, "GuideML",
  2907.             WINDOW_AppPort, AppPort,
  2908.             WINDOW_Position, WPOS_CENTERMOUSE,
  2909.             WINDOW_ParentGroup, gadgets[GID_MAIN] = VGroupObject,
  2910.                 LAYOUT_SpaceOuter, TRUE,
  2911.                 LAYOUT_AddChild, gadgets[GID_TABS] = ClickTabObject,
  2912.                     GA_ID, GID_TABS,
  2913.                   GA_RelVerify, TRUE,
  2914.                   CLICKTAB_Labels,&tablist,
  2915.                       CLICKTAB_PageGroup, PageObject,
  2916.                         PAGE_Add,LayoutObject,
  2917.                             LAYOUT_AddChild,VGroupObject,
  2918.                                     LAYOUT_SpaceOuter,TRUE,
  2919.                                 LAYOUT_AddChild, gadgets[GID_FILE] = GetFileObject,
  2920.                                     GA_ID, GID_FILE,
  2921.                                     GA_RelVerify, TRUE,
  2922.                                     GETFILE_TitleText,"GuideML",
  2923.                                         GETFILE_Pattern,"#?.guide",
  2924.                                         GETFILE_DoPatterns,TRUE,
  2925.                                         GETFILE_ReadOnly,FALSE,
  2926.                                         GETFILE_FullFile,param.from,
  2927.                                 End,
  2928.                                 CHILD_Label, LabelObject,
  2929.                                 LABEL_Text, "_Input File",
  2930.                                 LabelEnd,
  2931.                                 CHILD_NominalSize, TRUE,
  2932.                                 LAYOUT_AddChild, gadgets[GID_TO] = GetFileObject,
  2933.                                     GA_ID, GID_TO,
  2934.                                     GA_RelVerify, TRUE,
  2935.                                     GETFILE_TitleText,"GuideML",
  2936.                                         GETFILE_DoSaveMode,TRUE,
  2937.                                         GETFILE_DrawersOnly,TRUE,
  2938.                                         GETFILE_ReadOnly,FALSE,
  2939.                                         GETFILE_Drawer,param.to,
  2940.                                 End,
  2941.                                 CHILD_Label, LabelObject,
  2942.                                 LABEL_Text, "_Output Path",
  2943.                                 LabelEnd,
  2944.                                 CHILD_NominalSize, TRUE,
  2945.                                 LAYOUT_AddChild, gadgets[GID_HOMEURL] = StringObject,
  2946.                                     GA_ID, GID_HOMEURL,
  2947.                                     GA_RelVerify, TRUE,
  2948.                                     STRINGA_TextVal,param.homeurl,
  2949.                                     STRINGA_MaxChars,100,
  2950.                                 End,
  2951.                                 CHILD_Label, LabelObject,
  2952.                                 LABEL_Text, "_Home URL",
  2953.                                 LabelEnd,
  2954.                                 CHILD_NominalSize, TRUE,
  2955.                                 LAYOUT_AddChild, gadgets[GID_FINDURL] = StringObject,
  2956.                                     GA_ID, GID_FINDURL,
  2957.                                     GA_RelVerify, TRUE,
  2958.                                     STRINGA_TextVal,param.findurl,
  2959.                                     STRINGA_MaxChars,100,
  2960.                                 End,
  2961.                                 CHILD_Label, LabelObject,
  2962.                                 LABEL_Text, "_Search URL",
  2963.                                 LabelEnd,
  2964.                                 CHILD_NominalSize, TRUE,
  2965.                                 LAYOUT_AddChild, gadgets[GID_CSS] = StringObject,
  2966.                                     GA_ID, GID_CSS,
  2967.                                     GA_RelVerify, TRUE,
  2968.                                     STRINGA_TextVal,param.cssurl,
  2969.                                     STRINGA_MaxChars,100,
  2970.                                 End,
  2971.                                 CHILD_Label, LabelObject,
  2972.                                 LABEL_Text, "CSS _URL",
  2973.                                 LabelEnd,
  2974.                                 CHILD_NominalSize, TRUE,
  2975.                                 LAYOUT_AddChild, gadgets[GID_LA] = StringObject,
  2976.                                     GA_ID, GID_LA,
  2977.                                     GA_RelVerify, TRUE,
  2978.                                     STRINGA_TextVal,param.linkadd,
  2979.                                     STRINGA_MaxChars,100,
  2980.                                 End,
  2981.                                 CHILD_Label, LabelObject,
  2982.                                 LABEL_Text, "_Link Prefix",
  2983.                                 LabelEnd,
  2984.                                 CHILD_NominalSize, TRUE,
  2985.                                 LAYOUT_AddChild, gadgets[GID_BODY] = StringObject,
  2986.                                     GA_ID, GID_BODY,
  2987.                                     GA_RelVerify, TRUE,
  2988.                                     STRINGA_TextVal,param.bodyext,
  2989.                                     STRINGA_MaxChars,100,
  2990.                                 End,
  2991.                                 CHILD_Label, LabelObject,
  2992.                                 LABEL_Text, "_Body",
  2993.                                 LabelEnd,
  2994.                                 CHILD_NominalSize, TRUE,
  2995.                                 LAYOUT_AddChild, gadgets[GID_HTMLHEADF] = GetFileObject,
  2996.                                     GA_ID, GID_HTMLHEADF,
  2997.                                     GA_RelVerify, TRUE,
  2998.                                     GETFILE_TitleText,"GuideML",
  2999.                                         GETFILE_Pattern,"#?.(s|%)htm(l|%)",
  3000.                                         GETFILE_DoPatterns,TRUE,
  3001.                                         GETFILE_ReadOnly,FALSE,
  3002.                                         GETFILE_FullFile,param.htmlheadf,
  3003.                                 End,
  3004.                                 CHILD_Label, LabelObject,
  3005.                                 LABEL_Text, "HTML H_eader",
  3006.                                 LabelEnd,
  3007.                                 LAYOUT_AddChild, gadgets[GID_HTMLFOOTF] = GetFileObject,
  3008.                                     GA_ID, GID_HTMLFOOTF,
  3009.                                     GA_RelVerify, TRUE,
  3010.                                     GETFILE_TitleText,"GuideML",
  3011.                                         GETFILE_Pattern,"#?.(s|%)htm(l|%)",
  3012.                                         GETFILE_DoPatterns,TRUE,
  3013.                                         GETFILE_ReadOnly,FALSE,
  3014.                                         GETFILE_FullFile,param.htmlfootf,
  3015.                                 End,
  3016.                                 CHILD_Label, LabelObject,
  3017.                                 LABEL_Text, "HTML _Footer",
  3018.                                 LabelEnd,
  3019.  
  3020.                                 LayoutEnd,
  3021.                             LayoutEnd,
  3022.                         PAGE_Add,LayoutObject,
  3023.                            LAYOUT_AddChild,VGroupObject,
  3024.                                LAYOUT_AddChild,HGroupObject,
  3025.                                      LAYOUT_AddChild,VGroupObject,
  3026.                                             LAYOUT_SpaceOuter,TRUE,
  3027.                                         LAYOUT_AddChild, gadgets[GID_WRAP] = ChooserObject,
  3028.                                             GA_ID, GID_WRAP,
  3029.                                             GA_RelVerify, TRUE,
  3030.                                           CHOOSER_PopUp,TRUE,
  3031.                                           CHOOSER_Labels,&optlist,
  3032.                                             CHOOSER_Selected,wrapm,
  3033.                                             CHOOSER_AutoFit,TRUE,
  3034.                                         ChooserEnd,
  3035.                                         CHILD_Label, LabelObject,
  3036.                                         LABEL_Text, "_Wrap mode",
  3037.                                         LabelEnd,
  3038.                                         CHILD_NominalSize, TRUE,
  3039.  
  3040.                                         LAYOUT_AddChild, gadgets[GID_NAVBAR] = ChooserObject,
  3041.                                             GA_ID, GID_NAVBAR,
  3042.                                             GA_RelVerify, TRUE,
  3043.                                           CHOOSER_PopUp,TRUE,
  3044.                                           CHOOSER_Labels,&navoptlist,
  3045.                                             CHOOSER_Selected,navm,
  3046.                                             CHOOSER_AutoFit,TRUE,
  3047.                                         ChooserEnd,
  3048.                                         CHILD_Label, LabelObject,
  3049.                                         LABEL_Text, "_Nav bar",
  3050.                                         LabelEnd,
  3051.                                         CHILD_NominalSize, TRUE,
  3052.  
  3053.                                         LAYOUT_AddChild, gadgets[GID_IMAGES] = ChooserObject,
  3054.                                             GA_ID, GID_IMAGES,
  3055.                                             GA_RelVerify, TRUE,
  3056.                                           CHOOSER_PopUp,TRUE,
  3057.                                           CHOOSER_Labels,&imgoptlist,
  3058.                                             CHOOSER_Selected,param.images,
  3059.                                             CHOOSER_AutoFit,TRUE,
  3060.                                         ChooserEnd,
  3061.                                         CHILD_Label, LabelObject,
  3062.                                         LABEL_Text, "_Style",
  3063.                                         LabelEnd,
  3064.                                         CHILD_NominalSize, TRUE,
  3065.  
  3066.                                         LAYOUT_AddChild, gadgets[GID_LINKS] = ChooserObject,
  3067.                                             GA_ID, GID_LINKS,
  3068.                                             GA_RelVerify, TRUE,
  3069.                                           CHOOSER_PopUp,TRUE,
  3070.                                           CHOOSER_Labels,&linkoptlist,
  3071.                                             CHOOSER_Selected,linkm,
  3072.                                             CHOOSER_AutoFit,TRUE,
  3073.                                         ChooserEnd,
  3074.                                         CHILD_Label, LabelObject,
  3075.                                         LABEL_Text, "_Links",
  3076.                                         LabelEnd,
  3077.                                         CHILD_NominalSize, TRUE,
  3078.  
  3079.                                         LAYOUT_AddChild, gadgets[GID_PREV] = StringObject,
  3080.                                             GA_ID, GID_PREV,
  3081.                                             GA_RelVerify, TRUE,
  3082.                                             STRINGA_TextVal,param.prev,
  3083.                                             STRINGA_MaxChars,100,
  3084.                                         End,
  3085.                                         CHILD_Label, LabelObject,
  3086.                                         LABEL_Text, "_Previous",
  3087.                                         LabelEnd,
  3088.                                             CHILD_NominalSize, TRUE,
  3089.                                         LAYOUT_AddChild, gadgets[GID_NEXT] = StringObject,
  3090.                                             GA_ID, GID_NEXT,
  3091.                                             GA_RelVerify, TRUE,
  3092.                                             STRINGA_TextVal,param.next,
  3093.                                             STRINGA_MaxChars,100,
  3094.                                         End,
  3095.                                         CHILD_Label, LabelObject,
  3096.                                         LABEL_Text, "Nex_t",
  3097.                                         LabelEnd,
  3098.                                             CHILD_NominalSize, TRUE,
  3099.                                         LAYOUT_AddChild, gadgets[GID_INDEX] = StringObject,
  3100.                                             GA_ID, GID_INDEX,
  3101.                                             GA_RelVerify, TRUE,
  3102.                                             STRINGA_TextVal,param.index,
  3103.                                             STRINGA_MaxChars,100,
  3104.                                         End,
  3105.                                         CHILD_Label, LabelObject,
  3106.                                         LABEL_Text, "Inde_x",
  3107.                                         LabelEnd,
  3108.                                             CHILD_NominalSize, TRUE,
  3109.                                         LAYOUT_AddChild, gadgets[GID_TOC] = StringObject,
  3110.                                             GA_ID, GID_TOC,
  3111.                                             GA_RelVerify, TRUE,
  3112.                                             STRINGA_TextVal,param.toc,
  3113.                                             STRINGA_MaxChars,100,
  3114.                                         End,
  3115.                                         CHILD_Label, LabelObject,
  3116.                                         LABEL_Text, "C_ontents",
  3117.                                         LabelEnd,
  3118.                                             CHILD_NominalSize, TRUE,
  3119.  
  3120.                                         LAYOUT_AddChild, gadgets[GID_HELP] = StringObject,
  3121.                                             GA_ID, GID_HELP,
  3122.                                             GA_RelVerify, TRUE,
  3123.                                             STRINGA_TextVal,param.help,
  3124.                                             STRINGA_MaxChars,100,
  3125.                                         End,
  3126.                                         CHILD_Label, LabelObject,
  3127.                                         LABEL_Text, "H_elp",
  3128.                                         LabelEnd,
  3129.                                             CHILD_NominalSize, TRUE,
  3130.  
  3131.                                         LayoutEnd,
  3132.  
  3133.                                    LAYOUT_AddChild,VGroupObject,
  3134.                                         LAYOUT_AddChild, gadgets[GID_VARWIDTH] = CheckBoxObject,
  3135.                                             GA_ID, GID_VARWIDTH,
  3136.                                             GA_RelVerify, TRUE,
  3137.                                             GA_Text,"_Variable Width Font",
  3138.                                             GA_Selected,param.varwidth,
  3139.                                             CHECKBOX_TextPlace,PLACETEXT_LEFT,
  3140.                                         CheckBoxEnd,
  3141.                                         CHILD_NominalSize, TRUE,
  3142.                                         LAYOUT_AddChild, gadgets[GID_MOZNAV] = CheckBoxObject,
  3143.                                             GA_ID, GID_MOZNAV,
  3144.                                             GA_RelVerify, TRUE,
  3145.                                             GA_Text,"_Mozilla Site Navigation Bar",
  3146.                                             GA_Selected,param.nomoznav+1,
  3147.                                             CHECKBOX_TextPlace,PLACETEXT_LEFT,
  3148.                                         CheckBoxEnd,
  3149.                                         CHILD_NominalSize, TRUE,
  3150.                                         LAYOUT_AddChild, gadgets[GID_SHOWALL] = CheckBoxObject,
  3151.                                             GA_ID, GID_SHOWALL,
  3152.                                             GA_RelVerify, TRUE,
  3153.                                             GA_Text,"Consistent _Across Pages",
  3154.                                             GA_Selected,param.showall,
  3155.                                             CHECKBOX_TextPlace,PLACETEXT_LEFT,
  3156.                                         CheckBoxEnd,
  3157.                                         CHILD_NominalSize, TRUE,
  3158.                                         LAYOUT_AddChild, gadgets[GID_MSDOS] = CheckBoxObject,
  3159.                                             GA_ID, GID_MSDOS,
  3160.                                             GA_RelVerify, TRUE,
  3161.                                             GA_Text,"MS-_DOS Compatible Filenames",
  3162.                                             GA_Selected,param.msdos,
  3163.                                             CHECKBOX_TextPlace,PLACETEXT_LEFT,
  3164.                                         CheckBoxEnd,
  3165.                                         CHILD_NominalSize, TRUE,
  3166.  
  3167.  
  3168.                                         LAYOUT_AddChild, gadgets[GID_NOHTML] = CheckBoxObject,
  3169.                                             GA_ID, GID_NOHTML,
  3170.                                             GA_RelVerify, TRUE,
  3171.                                             GA_Text,"Do Not Generate HTML _Headers",
  3172.                                             GA_Selected,param.nohtml,
  3173.                                             CHECKBOX_TextPlace,PLACETEXT_LEFT,
  3174.                                         CheckBoxEnd,
  3175.                                         CHILD_NominalSize, TRUE,
  3176.  
  3177.                                         LAYOUT_AddChild, gadgets[GID_SINGLEFILE] = CheckBoxObject,
  3178.                                             GA_ID, GID_SINGLEFILE,
  3179.                                             GA_RelVerify, TRUE,
  3180.                                             GA_Text,"S_ingle HTML File",
  3181.                                             GA_Selected,param.singlefile,
  3182.                                             CHECKBOX_TextPlace,PLACETEXT_LEFT,
  3183.                                         CheckBoxEnd,
  3184.                                         CHILD_NominalSize, TRUE,
  3185.  
  3186.                                         LAYOUT_AddChild, gadgets[GID_RETRACE] = StringObject,
  3187.                                             GA_ID, GID_RETRACE,
  3188.                                             GA_RelVerify, TRUE,
  3189.                                             STRINGA_TextVal,param.retrace,
  3190.                                             STRINGA_MaxChars,100,
  3191.                                         End,
  3192.                                         CHILD_Label, LabelObject,
  3193.                                         LABEL_Text, "_Retrace",
  3194.                                         LabelEnd,
  3195.                                             CHILD_NominalSize, TRUE,
  3196.                                         LAYOUT_AddChild, gadgets[GID_HOME] = StringObject,
  3197.                                             GA_ID, GID_HOME,
  3198.                                             GA_RelVerify, TRUE,
  3199.                                             STRINGA_TextVal,param.home,
  3200.                                             STRINGA_MaxChars,100,
  3201.                                         End,
  3202.                                         CHILD_Label, LabelObject,
  3203.                                         LABEL_Text, "H_ome",
  3204.                                         LabelEnd,
  3205.                                             CHILD_NominalSize, TRUE,
  3206.                                         LAYOUT_AddChild, gadgets[GID_FIND] = StringObject,
  3207.                                             GA_ID, GID_FIND,
  3208.                                             GA_RelVerify, TRUE,
  3209.                                             STRINGA_TextVal,param.find,
  3210.                                             STRINGA_MaxChars,100,
  3211.                                         End,
  3212.                                         CHILD_Label, LabelObject,
  3213.                                         LABEL_Text, "S_earch",
  3214.                                         LabelEnd,
  3215.                                             CHILD_NominalSize, TRUE,
  3216.                                         LAYOUT_AddChild, gadgets[GID_BAR] = StringObject,
  3217.                                             GA_ID, GID_BAR,
  3218.                                             GA_RelVerify, TRUE,
  3219.                                             STRINGA_TextVal,param.bar,
  3220.                                             STRINGA_MaxChars,10,
  3221.                                         End,
  3222.                                         CHILD_Label, LabelObject,
  3223.                                         LABEL_Text, "_Bar",
  3224.                                         LabelEnd,
  3225.                                             CHILD_NominalSize, TRUE,
  3226.  
  3227.                                         LayoutEnd,
  3228.                                     LayoutEnd,
  3229.                                 LayoutEnd,
  3230.                             LayoutEnd,
  3231.                         PageEnd,
  3232.                    ClickTabEnd,
  3233.  
  3234.                 LAYOUT_AddChild, HGroupObject,
  3235.                     GA_BackFill, NULL,
  3236.                     LAYOUT_SpaceOuter, FALSE,
  3237.                     LAYOUT_VertAlignment, LALIGN_CENTER,
  3238.                     LAYOUT_HorizAlignment, LALIGN_CENTER,
  3239.                           LAYOUT_AddChild, gadgets[GID_CONV] = ButtonObject,
  3240.                             GA_ID, GID_CONV,
  3241.                             GA_RelVerify, TRUE,
  3242.                             GA_Text,"_Convert",
  3243.                         ButtonEnd,
  3244.                 LayoutEnd,
  3245.                 CHILD_WeightedHeight, 0,
  3246.             EndGroup,
  3247.         EndWindow;
  3248.  
  3249.  
  3250.          /*  Object creation sucessful?
  3251.           */
  3252.         if (objects[OID_MAIN])
  3253.         {
  3254.             /*  Open the window.
  3255.              */
  3256.             if (windows[WID_MAIN] = (struct Window *) RA_OpenWindow(objects[OID_MAIN]))
  3257.             {
  3258.                 ULONG wait, signal, app = (1L << AppPort->mp_SigBit);
  3259.                 ULONG done = FALSE;
  3260.                 ULONG result;
  3261.                 UWORD code;
  3262.  
  3263.                     menustrip = addmenu(windows[WID_MAIN]);
  3264.  
  3265.                  /* Obtain the window wait signal mask.
  3266.                  */
  3267.                 IIntuition->GetAttr(WINDOW_SigMask, objects[OID_MAIN], &signal);
  3268.  
  3269.                 /* Input Event Loop
  3270.                  */
  3271.                 while (!done)
  3272.                 {
  3273.                     wait = IExec->Wait( signal | SIGBREAKF_CTRL_C | app );
  3274.  
  3275.                             if(wait & SIGBREAKF_CTRL_C)
  3276.                                 {
  3277.                         done = TRUE;
  3278.                                 }
  3279.                             else
  3280.                                 {
  3281.                         while ( (result = RA_HandleInput(objects[OID_MAIN], &code) ) != WMHI_LASTMSG )
  3282.                         {
  3283.                             switch (result & WMHI_CLASSMASK)
  3284.                             {
  3285.                                 case WMHI_CLOSEWINDOW:
  3286.                                     windows[WID_MAIN] = NULL;
  3287.                                     done = TRUE;
  3288.                                     break;
  3289.  
  3290.                                 case WMHI_MENUPICK:
  3291.                                         while (code !=MENUNULL)
  3292.                                         {
  3293.                                             //menusel = code;
  3294.                                             item = IIntuition->ItemAddress(menustrip,code);
  3295.                                             menunum = MENUNUM(code);
  3296.                                             itemnum = ITEMNUM(code);
  3297.                                             subnum = SUBNUM(code);
  3298.  
  3299.                                             switch(menunum)
  3300.                                             {
  3301.                                                 case 0:  // Project
  3302.                                                     switch(itemnum)
  3303.                                                     {
  3304.  
  3305.                                                         case 0: // save
  3306.                                                                     IIntuition->SetWindowPointer(windows[WID_MAIN],WA_BusyPointer,TRUE,WA_PointerDelay,TRUE,TAG_DONE);
  3307.                                                                      saveas();
  3308.                                                                     IIntuition->SetWindowPointer(windows[WID_MAIN],TAG_DONE);
  3309.                                                         break;
  3310.  
  3311.                                                         case 2: // about
  3312.  
  3313.                                                             err("GuideML "VERSIONSTR"\n\n© 1997-8 Richard Körber\nhttp://www.shredzone.de\n\n© 2001-4 Chris Young\nhttp://www.unsatisfactorysoftware.co.uk","OK",0);
  3314.                                                         break;
  3315.  
  3316.                                                         case 4: // quit
  3317.  
  3318.                                                         windows[WID_MAIN] = NULL;
  3319.                                                         done = TRUE;
  3320.  
  3321.                                                         break;
  3322.  
  3323.                                                     }
  3324.                                                 break;
  3325.  
  3326.                                                 case 1: // Settings
  3327.                                                     switch(itemnum)
  3328.                                                     {
  3329.                                                         case 0:
  3330.                                                          // save defaults
  3331.                                                                 IIntuition->SetWindowPointer(windows[WID_MAIN],WA_BusyPointer,TRUE,WA_PointerDelay,TRUE,TAG_DONE);
  3332.                                                          savetooltypes(defname,1);
  3333.                                                                 IIntuition->SetWindowPointer(windows[WID_MAIN],TAG_DONE);
  3334.                                                         break;
  3335.                                                     }
  3336.                                                 break;
  3337.  
  3338.  
  3339.                                             }
  3340.  
  3341.  
  3342.                                             code = item->NextSelect;
  3343.                                         }
  3344.                                         break;
  3345.  
  3346.                                 case WMHI_GADGETUP:
  3347.                                     switch (result & WMHI_GADGETMASK)
  3348.                                     {
  3349.                                         case GID_FILE:
  3350.                                             if(IIntuition->IDoMethod((Object *)gadgets[GID_FILE],GFILE_REQUEST,windows[WID_MAIN]))
  3351.                                             {
  3352.                                                 IIntuition->GetAttr(GETFILE_FullFile,gadgets[GID_FILE],(ULONG*)¶m.from);
  3353.                                             }
  3354.  
  3355.                                           break;
  3356.  
  3357.                                         case GID_TO:
  3358.                                             if(IIntuition->IDoMethod((Object *)gadgets[GID_TO],GFILE_REQUEST,windows[WID_MAIN]))
  3359.                                             {
  3360.                                                 IIntuition->GetAttr(GETFILE_Drawer,gadgets[GID_TO],(ULONG*)¶m.to);
  3361.                                             }
  3362.  
  3363.                                           break;
  3364.                                         case GID_HTMLHEADF:
  3365.                                             if(IIntuition->IDoMethod((Object *)gadgets[GID_HTMLHEADF],GFILE_REQUEST,windows[WID_MAIN]))
  3366.                                             {
  3367.                                                 IIntuition->GetAttr(GETFILE_FullFile,gadgets[GID_HTMLHEADF],(ULONG*)¶m.htmlheadf);
  3368.                                             }
  3369.                                               if(param.htmlheadf)
  3370.                                                   {
  3371.                                                       if(strlen(param.htmlheadf)==0) param.htmlheadf=0;
  3372.                                                   }
  3373.  
  3374.                                           break;
  3375.                                         case GID_HTMLFOOTF:
  3376.                                             if(IIntuition->IDoMethod((Object *)gadgets[GID_HTMLFOOTF],GFILE_REQUEST,windows[WID_MAIN]))
  3377.                                             {
  3378.                                                 IIntuition->GetAttr(GETFILE_FullFile,gadgets[GID_HTMLFOOTF],(ULONG*)¶m.htmlfootf);
  3379.                                             }
  3380.                                               if(param.htmlfootf)
  3381.                                                   {
  3382.                                                       if(strlen(param.htmlfootf)==0) param.htmlfootf=0;
  3383.                                                             }
  3384.                                           break;
  3385.  
  3386.                                         case GID_BODY:
  3387.                                               IIntuition->GetAttr(STRINGA_TextVal,gadgets[GID_BODY],(ULONG*)¶m.bodyext);
  3388.                                               if(strlen(param.bodyext)==0) param.bodyext=0;
  3389.                                         break;
  3390.                                         case GID_CSS:
  3391.                                               IIntuition->GetAttr(STRINGA_TextVal,gadgets[GID_CSS],(ULONG*)¶m.cssurl);
  3392.                                               if(strlen(param.cssurl)==0) param.cssurl=0;
  3393.                                         break;
  3394.                                         case GID_LA:
  3395.                                               IIntuition->GetAttr(STRINGA_TextVal,gadgets[GID_LA],(ULONG*)¶m.linkadd);
  3396.                                               if(strlen(param.linkadd)==0) param.linkadd=0;
  3397.                                         break;
  3398.                                         case GID_HOMEURL:
  3399.                                               IIntuition->GetAttr(STRINGA_TextVal,gadgets[GID_HOMEURL],(ULONG*)¶m.homeurl);
  3400.                                               if(strlen(param.homeurl)==0) param.homeurl=0;
  3401.                                         break;
  3402.  
  3403.                                         case GID_FINDURL:
  3404.                                               IIntuition->GetAttr(STRINGA_TextVal,gadgets[GID_FINDURL],(ULONG*)¶m.findurl);
  3405.                                               if(strlen(param.findurl)==0) param.findurl=0;
  3406.                                         break;
  3407.  
  3408.                                         case GID_RETRACE:
  3409.                                               IIntuition->GetAttr(STRINGA_TextVal,gadgets[GID_RETRACE],(ULONG*)¶m.retrace);
  3410.                                               if(strlen(param.retrace)==0) param.retrace=0;
  3411.                                         break;
  3412.  
  3413.                                         case GID_PREV:
  3414.                                               IIntuition->GetAttr(STRINGA_TextVal,gadgets[GID_PREV],(ULONG*)¶m.prev);
  3415.                                               if(strlen(param.prev)==0) param.prev=0;
  3416.                                         break;
  3417.  
  3418.                                         case GID_NEXT:
  3419.                                               IIntuition->GetAttr(STRINGA_TextVal,gadgets[GID_NEXT],(ULONG*)¶m.next);
  3420.                                               if(strlen(param.next)==0) param.next=0;
  3421.                                         break;
  3422.  
  3423.                                         case GID_INDEX:
  3424.                                               IIntuition->GetAttr(STRINGA_TextVal,gadgets[GID_INDEX],(ULONG*)¶m.index);
  3425.                                               if(strlen(param.index)==0) param.index=0;
  3426.                                         break;
  3427.  
  3428.                                         case GID_TOC:
  3429.                                               IIntuition->GetAttr(STRINGA_TextVal,gadgets[GID_TOC],(ULONG*)¶m.toc);
  3430.                                               if(strlen(param.toc)==0) param.toc=0;
  3431.                                         break;
  3432.  
  3433.                                         case GID_HELP:
  3434.                                               IIntuition->GetAttr(STRINGA_TextVal,gadgets[GID_HELP],(ULONG*)¶m.help);
  3435.                                               if(strlen(param.help)==0) param.help=0;
  3436.                                         break;
  3437.  
  3438.                                         case GID_FIND:
  3439.                                               IIntuition->GetAttr(STRINGA_TextVal,gadgets[GID_FIND],(ULONG*)¶m.find);
  3440.                                               if(strlen(param.find)==0) param.find=0;
  3441.                                         break;
  3442.  
  3443.                                         case GID_HOME:
  3444.                                               IIntuition->GetAttr(STRINGA_TextVal,gadgets[GID_HOME],(ULONG*)¶m.home);
  3445.                                               if(strlen(param.home)==0) param.home=0;
  3446.                                         break;
  3447.  
  3448.                                         case GID_BAR:
  3449.                                               IIntuition->GetAttr(STRINGA_TextVal,gadgets[GID_BAR],(ULONG*)¶m.bar);
  3450.                                         break;
  3451.  
  3452.                                         case GID_CONV:
  3453.                                             if(!param.from)
  3454.                                                 {
  3455.                                                     err("You must select an AmigaGuide\ndocument to convert!","OK",0);
  3456.                                                 }
  3457.                                                 else
  3458.                                                 {
  3459.                                                                 IIntuition->SetWindowPointer(windows[WID_MAIN],WA_BusyPointer,TRUE,TAG_DONE);
  3460.                                                     main(1,0);
  3461.                                                                   param.prev = textlabs.prev;
  3462.                                                                   param.next = textlabs.next;
  3463.                                                                   param.index = textlabs.index;
  3464.                                                                   param.toc = textlabs.toc;
  3465.                                                                   param.home = textlabs.home;
  3466.                                                                   param.help = textlabs.help;
  3467.                                                                   param.find = textlabs.find;
  3468.                                                                   param.retrace = textlabs.retrace;
  3469.                                                                   param.bar = textlabs.bar;
  3470.                                                                 IIntuition->SetWindowPointer(windows[WID_MAIN],TAG_DONE);
  3471.                                                 }
  3472.                                         break;
  3473.  
  3474.                                         case GID_WRAP:
  3475.  
  3476.                                                         switch(code)
  3477.                                                         {
  3478.                                                             case 0:
  3479.                                                                 param.noauto=0;
  3480.                                                                 param.wordwrap=0;
  3481.                                                                 param.smartwrap=0;
  3482.                                                                 IIntuition->SetAttrs(gadgets[GID_VARWIDTH],GA_Disabled,FALSE,TAG_DONE);
  3483.                                                                   ILayout->RethinkLayout(gadgets[GID_VARWIDTH],windows[WID_MAIN],NULL,TRUE);
  3484.                                                             break;
  3485.  
  3486.                                                             case 1:
  3487.                                                                 param.wordwrap=TRUE;
  3488.                                                                 param.smartwrap=FALSE;
  3489.                                                                 param.noauto=TRUE;
  3490.                                                                 IIntuition->SetAttrs(gadgets[GID_VARWIDTH],GA_Disabled,FALSE,TAG_DONE);
  3491.                                                                   ILayout->RethinkLayout(gadgets[GID_VARWIDTH],windows[WID_MAIN],NULL,TRUE);
  3492.                                                             break;
  3493.  
  3494.                                                             case 2:
  3495.                                                                 param.wordwrap=FALSE;
  3496.                                                                 param.smartwrap=TRUE;
  3497.                                                                 param.noauto=TRUE;
  3498.                                                                 IIntuition->SetAttrs(gadgets[GID_VARWIDTH],GA_Disabled,FALSE,TAG_DONE);
  3499.                                                                   ILayout->RethinkLayout(gadgets[GID_VARWIDTH],windows[WID_MAIN],NULL,TRUE);
  3500.                                                             break;
  3501.  
  3502.                                                             case 3:
  3503.                                                                 param.wordwrap=FALSE;
  3504.                                                                 param.smartwrap=FALSE;
  3505.                                                                 param.noauto=TRUE;
  3506.                                                                 IIntuition->SetAttrs(gadgets[GID_VARWIDTH],GA_Disabled,TRUE,TAG_DONE);
  3507.                                                                   ILayout->RethinkLayout(gadgets[GID_VARWIDTH],windows[WID_MAIN],NULL,TRUE);
  3508.                                                             break;
  3509.  
  3510.                                                         }
  3511.  
  3512.                                         break;
  3513.  
  3514.                                         case GID_VARWIDTH:
  3515.                                             param.varwidth=code;
  3516.                                         break;
  3517.  
  3518.                                         case GID_SINGLEFILE:
  3519.                                             param.singlefile=code;
  3520.                                             if(param.singlefile)
  3521.                                             {
  3522.                                                 IIntuition->SetAttrs(gadgets[GID_LA],GA_Disabled,TRUE,TAG_DONE);
  3523.                                                 ILayout->RethinkLayout(gadgets[GID_LA],windows[WID_MAIN],NULL,TRUE);
  3524.                                             }
  3525.                                             else
  3526.                                             {
  3527.                                                 IIntuition->SetAttrs(gadgets[GID_LA],GA_Disabled,FALSE,TAG_DONE);
  3528.                                                 ILayout->RethinkLayout(gadgets[GID_LA],windows[WID_MAIN],NULL,TRUE);
  3529.                                             }
  3530.  
  3531.  
  3532.  
  3533.                                         break;
  3534.  
  3535.                                         case GID_NOHTML:
  3536.                                             param.nohtml=code;
  3537.                                         break;
  3538.  
  3539.                                         case GID_NAVBAR:
  3540.  
  3541.                                                         switch(code)
  3542.                                                         {
  3543.                                                             case 0:
  3544.                                                                 param.nonavbar=FALSE;
  3545.                                                                 param.footer=FALSE;
  3546.                                                                 IIntuition->SetAttrs(gadgets[GID_IMAGES],GA_Disabled,FALSE,TAG_DONE);
  3547.                                                                   ILayout->RethinkLayout(gadgets[GID_IMAGES],windows[WID_MAIN],NULL,TRUE);
  3548.                                                             break;
  3549.  
  3550.                                                             case 1:
  3551.                                                                 param.nonavbar=FALSE;
  3552.                                                                 param.footer=TRUE;
  3553.                                                                 IIntuition->SetAttrs(gadgets[GID_IMAGES],GA_Disabled,FALSE,TAG_DONE);
  3554.                                                                   ILayout->RethinkLayout(gadgets[GID_IMAGES],windows[WID_MAIN],NULL,TRUE);
  3555.                                                             break;
  3556.  
  3557.                                                             case 2:
  3558.                                                                 param.nonavbar=TRUE;
  3559.                                                                 param.footer=FALSE;
  3560.                                                                 IIntuition->SetAttrs(gadgets[GID_IMAGES],GA_Disabled,TRUE,TAG_DONE);
  3561.                                                                   ILayout->RethinkLayout(gadgets[GID_IMAGES],windows[WID_MAIN],NULL,TRUE);
  3562.                                                             break;
  3563.                                                         }
  3564.  
  3565.                                         break;
  3566.  
  3567.                                         case GID_LINKS:
  3568.  
  3569.                                                         switch(code)
  3570.                                                         {
  3571.                                                             case 0:
  3572.                                                                 param.noemail=FALSE;
  3573.                                                                 param.nolink=FALSE;
  3574.                                                             break;
  3575.  
  3576.                                                             case 1:
  3577.                                                                 param.noemail=TRUE;
  3578.                                                                 param.nolink=FALSE;
  3579.                                                             break;
  3580.  
  3581.                                                             case 2:
  3582.                                                                 param.noemail=FALSE;
  3583.                                                                 param.nolink=TRUE;
  3584.                                                             break;
  3585.  
  3586.                                                             case 3:
  3587.                                                                 param.noemail=TRUE;
  3588.                                                                 param.nolink=TRUE;
  3589.                                                             break;
  3590.                                                         }
  3591.                                         break;
  3592.  
  3593.                                         case GID_IMAGES:
  3594.                                             param.images=code;
  3595.                                         break;
  3596.  
  3597.                                         case GID_MOZNAV:
  3598.                                             param.nomoznav=code+1;
  3599.                                         break;
  3600.  
  3601.                                         case GID_SHOWALL:
  3602.                                             param.showall=code;
  3603.                                         break;
  3604.  
  3605.                                         case GID_MSDOS:
  3606.                                             param.msdos=code;
  3607.                                         break;
  3608.  
  3609.                                     }
  3610.                                     break;
  3611.  
  3612.                                 case WMHI_ICONIFY:
  3613.                                     RA_Iconify(objects[OID_MAIN]);
  3614.                                     windows[WID_MAIN] = NULL;
  3615.                                     break;
  3616.  
  3617.                                 case WMHI_UNICONIFY:
  3618.                                     windows[WID_MAIN] = (struct Window *) RA_OpenWindow(objects[OID_MAIN]);
  3619.  
  3620.                                     if (windows[WID_MAIN])
  3621.                                     {
  3622.                                         IIntuition->GetAttr(WINDOW_SigMask, objects[OID_MAIN], &signal);
  3623.                                     }
  3624.                                     else
  3625.                                     {
  3626.                                         done = TRUE;    // error re-opening window!
  3627.                                     }
  3628.                                      break;
  3629.                             }
  3630.                         }
  3631.                     }
  3632.                 }
  3633.             }
  3634.  
  3635.             /* Disposing of the window object will also close the window if it is
  3636.              * already opened, and it will dispose of the layout object attached to it.
  3637.              */
  3638.             IIntuition->DisposeObject(objects[OID_MAIN]);
  3639.         }
  3640.  
  3641.         IExec->DeleteMsgPort(AppPort);
  3642.     }
  3643. free_list(&optlist);
  3644. freetablist(&tablist);
  3645. IGadTools->FreeMenus(menustrip); // menu
  3646. cleanup(0);
  3647.  
  3648. /*
  3649.     closelibs();
  3650.  
  3651.     return(0);
  3652. */
  3653.  }
  3654.  
  3655.  
  3656. void free_list(struct List *list)
  3657. {
  3658.     struct Node *node,*nextnode;
  3659.     node = list ->lh_Head;
  3660.     while (nextnode = node->ln_Succ)
  3661.     {
  3662.         IChooser->FreeChooserNode(node);
  3663.         node=nextnode;
  3664.     }
  3665.     IExec->NewList(list);
  3666. }
  3667.  
  3668. void freetablist(struct List *list)
  3669. {
  3670.     struct Node *node,*nextnode;
  3671.     node = list ->lh_Head;
  3672.     while (nextnode = node->ln_Succ)
  3673.     {
  3674.         IClickTab->FreeClickTabNode(node);
  3675.         node=nextnode;
  3676.     }
  3677.     IExec->NewList(list);
  3678. }
  3679.  
  3680. BOOL make_list(struct List *list, UBYTE **labels1)
  3681. {
  3682.     struct Node *node;
  3683.     WORD i = 0;
  3684.     int ro=FALSE;
  3685.  
  3686.     IExec->NewList(list);
  3687.  
  3688.     while (*labels1)
  3689.     {
  3690.  
  3691.         if (node = IChooser->AllocChooserNode(
  3692.                             CNA_Text, *labels1,
  3693.                             CNA_ReadOnly, ro,
  3694.                         TAG_DONE))
  3695.         {
  3696.             IExec->AddTail(list, node);
  3697.         }
  3698.         else
  3699.             break;
  3700.  
  3701.         labels1++;
  3702.         i++;
  3703.         ro=FALSE;
  3704.     }
  3705.     return(TRUE);
  3706. }
  3707.  
  3708. BOOL maketablist(struct List *list, UBYTE **labels1)
  3709. {
  3710.     struct Node *node;
  3711.     WORD i = 0;
  3712.  
  3713.     IExec->NewList(list);
  3714.  
  3715.     while (*labels1)
  3716.     {
  3717.  
  3718.         if (node = IClickTab->AllocClickTabNode(
  3719.                             TNA_Text, *labels1,
  3720.                             TNA_Number, i,
  3721.                         TAG_DONE))
  3722.         {
  3723.             IExec->AddTail(list, node);
  3724.         }
  3725.         else
  3726.             break;
  3727.  
  3728.         labels1++;
  3729.         i++;
  3730.     }
  3731.     return(TRUE);
  3732. }
  3733.  
  3734. struct Menu *addmenu(struct Window *win)
  3735. {
  3736.  
  3737.  
  3738. APTR vi;
  3739.     struct Menu *menustrip;
  3740.     struct NewMenu menu[] = {
  3741.                                       {NM_TITLE,"Project"           , 0 ,0,0,0,},
  3742.                                       { NM_ITEM,"Save As..."        ,"S",0,0,0,},
  3743.                                       { NM_ITEM,NM_BARLABEL         , 0 ,0,0,0,},
  3744.                                       { NM_ITEM,"About..."          ,"A",0,0,0,},
  3745.                                       { NM_ITEM,NM_BARLABEL         , 0 ,0,0,0,},
  3746.                                       { NM_ITEM,"Quit"              ,"Q",0,0,0,},
  3747.                                       {NM_TITLE,"Settings"          , 0 ,0,0,0,},
  3748.                                       { NM_ITEM,"Save As Defaults"   ,"D",0,0,0,},
  3749.                                       {  NM_END,0,0,0,0,0,},
  3750.                                      };
  3751.  
  3752.     menustrip = IGadTools->CreateMenus(menu,GTMN_FullMenu,TRUE,TAG_DONE);
  3753.     vi = IGadTools->GetVisualInfoA(win->WScreen,TAG_DONE);
  3754.     IGadTools->LayoutMenus(menustrip,vi,GTMN_NewLookMenus,TRUE,TAG_DONE);
  3755. //                SetAttrs(win,WINDOW_MenuStrip,menustrip,TAG_DONE);
  3756.   IIntuition->SetMenuStrip(win,menustrip);
  3757.  
  3758. return(menustrip);
  3759. }
  3760.  
  3761.  int err(char *errtxt,char *gadgtxt,int fail)
  3762. {
  3763.     int rc;
  3764.  
  3765.     if(IIntuition)
  3766.     {
  3767.         struct EasyStruct errorreq =
  3768.             {
  3769.             sizeof(struct EasyStruct),
  3770.             0,
  3771.             "GuideML",
  3772.             errtxt,
  3773.             gadgtxt
  3774.             };
  3775.         rc = IIntuition->EasyRequest(NULL,&errorreq,NULL);
  3776.     }
  3777.     else
  3778.     {
  3779.         printf("%s\n",*errtxt);
  3780.     }
  3781.     if (fail) cleanup(fail);
  3782.  
  3783.     return(rc);
  3784. }
  3785.  
  3786. void cleanup(int fail)
  3787. {
  3788.     if(ttfrom) IExec->FreeMem(ttfrom,strlen(ttfrom)+1);
  3789.     if(ttto) IExec->FreeMem(ttto,strlen(ttto)+1);
  3790.     if(tthomeurl) IExec->FreeMem(tthomeurl,strlen(tthomeurl)+1);
  3791.     if(ttfindurl) IExec->FreeMem(ttfindurl,strlen(ttfindurl)+1);
  3792.     if(ttprev) IExec->FreeMem(ttprev,strlen(ttprev)+1);
  3793.     if(ttnext) IExec->FreeMem(ttnext,strlen(ttnext)+1);
  3794.     if(ttindex) IExec->FreeMem(ttindex,strlen(ttindex)+1);
  3795.     if(tttoc) IExec->FreeMem(tttoc,strlen(tttoc)+1);
  3796.     if(tthelp) IExec->FreeMem(tthelp,strlen(tthelp)+1);
  3797.     if(ttretrace) IExec->FreeMem(ttretrace,strlen(ttretrace)+1);
  3798.     if(tthome) IExec->FreeMem(tthome,strlen(tthome)+1);
  3799.     if(ttfind) IExec->FreeMem(ttfind,strlen(ttfind)+1);
  3800.     if(ttbar) IExec->FreeMem(ttbar,strlen(ttbar)+1);
  3801.     if(ttbody) IExec->FreeMem(ttbody,strlen(ttbody)+1);
  3802.     if(tthtmlheadf) IExec->FreeMem(tthtmlheadf,strlen(tthtmlheadf)+1);
  3803.     if(tthtmlfootf) IExec->FreeMem(tthtmlfootf,strlen(tthtmlfootf)+1);
  3804.     if(ttcss) IExec->FreeMem(ttcss,strlen(ttcss)+1);
  3805.  
  3806. if(GadToolsBase)
  3807. {
  3808.     IExec->DropInterface((struct Interface *)IGadTools);
  3809.     IExec->CloseLibrary(GadToolsBase);
  3810. }
  3811. if(UtilityBase)
  3812. {
  3813.     IExec->DropInterface((struct Interface *)IUtility);
  3814.     IExec->CloseLibrary(UtilityBase);
  3815. }
  3816.  
  3817. /*
  3818.      if(WindowBase) CloseLibrary(WindowBase);
  3819.      if(LayoutBase) CloseLibrary(LayoutBase);
  3820.      if(ButtonBase) CloseLibrary(ButtonBase);
  3821.      if(CheckBoxBase) CloseLibrary(CheckBoxBase);
  3822.      if(LabelBase) CloseLibrary(LabelBase);
  3823.      if(ChooserBase) CloseLibrary(ChooserBase);
  3824.      if(ClickTabBase) CloseLibrary(ClickTabBase);
  3825. //     if(IntegerBase) CloseLibrary(IntegerBase);
  3826. //     if(ListBrowserBase) CloseLibrary(ListBrowserBase);
  3827.      if(GetFileBase) CloseLibrary(GetFileBase);
  3828.      if(StringBase) CloseLibrary(StringBase);
  3829.      if(GadToolsBase) CloseLibrary(GadToolsBase);
  3830.      if(IconBase) CloseLibrary(IconBase);
  3831.  
  3832.  if(aslbase) CloseLibrary(aslbase);
  3833.  if(DOSBase) CloseLibrary(DOSBase);
  3834.  if(intuitionbase) CloseLibrary(intuitionbase);
  3835. */
  3836.  
  3837.  exit(fail);
  3838.  }
  3839.